Commit ad8dfd89 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

wip

parent 9df280f3
......@@ -14,7 +14,7 @@ import subprocess
import sys
import time
import traceback
import urllib2
from six.moves.urllib.request import urlopen
import urlparse
import uuid
......@@ -145,7 +145,7 @@ def main():
print('Fetching %s feed...' % args.feed_url[0])
feed = urllib2.urlopen(args.feed_url[0])
feed = urlopen(args.feed_url[0])
body = feed.read()
some_notification_failed = False
......
......@@ -33,8 +33,9 @@ import random
import ssl
import string
import time
import urllib
import urllib2
from six.moves.urllib.parse import quote
from six.moves.urllib.request import HTTPBasicAuthHandler, HTTPSHandler,
build_opener
class NotHttpOkException(Exception):
pass
......@@ -50,7 +51,7 @@ class ERP5TestSuite(SlaprunnerTestSuite):
Set inside of slaprunner the instance parameter to use to deploy erp5 instance.
"""
p = '<?xml version="1.0" encoding="utf-8"?> <instance> <parameter id="_">{"zodb-zeo": {"backup-periodicity": "*:1/4"}, "mariadb": {"backup-periodicity": "*:1/4"}}</parameter> </instance>'
parameter = urllib2.quote(p)
parameter = quote(p)
self._connectToSlaprunner(
resource='saveParameterXml',
data='software_type=default&parameter=%s' % parameter)
......@@ -109,7 +110,7 @@ class ERP5TestSuite(SlaprunnerTestSuite):
resource='/saveFileContent',
data='file=runner_workdir%%2Finstance%%2F%s%%2Fetc%%2Fhaproxy.cfg&content=%s' % (
haproxy_slappart,
urllib.quote(file_content),
quote(file_content),
)
)
......@@ -133,12 +134,12 @@ class ERP5TestSuite(SlaprunnerTestSuite):
def _connectToERP5(self, url, data=None, password=None):
if password is None:
password = self._getERP5Password()
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler = HTTPBasicAuthHandler()
auth_handler.add_password(realm='Zope', uri=url, user='zope', passwd=password)
ssl_context = ssl._create_unverified_context()
opener_director = urllib2.build_opener(
opener_director = build_opener(
auth_handler,
urllib2.HTTPSHandler(context=ssl_context)
HTTPSHandler(context=ssl_context)
)
self.logger.info('Calling ERP5 url %s' % url)
......
......@@ -32,7 +32,7 @@ import logging
import random
import string
import time
import urllib
from six.moves.urllib.request import urlopen
logger = logging.getLogger('KVMResiliencyTest')
......@@ -45,7 +45,7 @@ def fetchKey(ip):
new_key = None
for i in range(0, 10):
try:
new_key = urllib.urlopen('http://%s:10080/get' % ip).read().strip()
new_key = urlopen('http://%s:10080/get' % ip).read().strip()
break
except IOError:
logger.error('Server in new KVM does not answer.')
......@@ -148,7 +148,7 @@ class KVMTestSuite(ResiliencyTestSuite):
for i in range(0, 60):
failure = False
try:
connection = urllib.urlopen('http://%s:10080/set?key=%s' % (self.ip, self.key))
connection = urlopen('http://%s:10080/set?key=%s' % (self.ip, self.key))
if connection.getcode() is 200:
break
else:
......
......@@ -34,7 +34,7 @@ import os
import subprocess
import sys
import time
import urllib2
from six.moves.urllib.request import urlopen
UNIT_TEST_ERP5TESTNODE = 'UnitTest'
......@@ -85,13 +85,13 @@ class ResiliencyTestSuite(object):
takeover_url = root_partition_parameter_dict['takeover-%s-%s-url' % (namebase, target_clone)]
takeover_password = root_partition_parameter_dict['takeover-%s-%s-password' % (namebase, target_clone)]
# Connect to takeover web interface
takeover_page_content = urllib2.urlopen(takeover_url).read()
takeover_page_content = urlopen(takeover_url).read()
# Wait for importer script to be not running
while 'Importer script(s) of backup in progress: True' in takeover_page_content:
time.sleep(10)
takeover_page_content = urllib2.urlopen(takeover_url).read()
takeover_page_content = urlopen(takeover_url).read()
# Do takeover
takeover_result = urllib2.urlopen('%s?password=%s' % (takeover_url, takeover_password)).read()
takeover_result = urlopen('%s?password=%s' % (takeover_url, takeover_password)).read()
if 'Error' in takeover_result:
raise Exception('Error while doing takeover: %s' % takeover_result)
......
......@@ -36,8 +36,9 @@ import random
import ssl
import string
import time
import urllib2
import urllib
from six.moves.urllib.request import HTTPCookieProcessor, HTTPSHandler,
build_opener
from six.moves.urllib.error import HTTPError
class NotHttpOkException(Exception):
pass
......@@ -52,9 +53,9 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
cookie_jar = cookielib.CookieJar()
ssl_context = ssl._create_unverified_context()
self._opener_director = urllib2.build_opener(
urllib2.HTTPCookieProcessor(cookie_jar),
urllib2.HTTPSHandler(context=ssl_context)
self._opener_director = build_opener(
HTTPCookieProcessor(cookie_jar),
HTTPSHandler(context=ssl_context)
)
ResiliencyTestSuite.__init__(self, *args, **kwargs)
......@@ -95,7 +96,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
if result.getcode() is not 200:
raise NotHttpOkException(result.getcode())
return result.read()
except urllib2.HTTPError:
except HTTPError:
self.logger.error('Error when contacting slaprunner at URL: {}'.format(url))
raise
......@@ -164,7 +165,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
"""
try:
return self._connectToSlaprunner(resource='isSRReady')
except (NotHttpOkException, urllib2.HTTPError) as error:
except (NotHttpOkException, HTTPError) as error:
# The nginx frontend might timeout before software release is finished.
self.logger.warning('Problem occured when contacting the server: %s' % error)
return -1
......@@ -187,7 +188,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
self.logger.info('Building the Software Release...')
try:
self._connectToSlaprunner(resource='runSoftwareProfile')
except (NotHttpOkException, urllib2.HTTPError):
except (NotHttpOkException, HTTPError):
# The nginx frontend might timeout before software release is finished.
pass
......@@ -197,7 +198,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
self.logger.info('Deploying instance...')
try:
self._connectToSlaprunner(resource='runInstanceProfile')
except (NotHttpOkException, urllib2.HTTPError):
except (NotHttpOkException, HTTPError):
# The nginx frontend might timeout before someftware release is finished.
pass
while True:
......@@ -219,7 +220,7 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
if data['code'] == 0:
self.logger.warning(data['result'])
except (NotHttpOkException, urllib2.HTTPError):
except (NotHttpOkException, HTTPError):
# cloning can be very long.
# XXX: quite dirty way to check.
while self._connectToSlaprunner('getProjectStatus', data='project=workspace/slapos').find('On branch master') == -1:
......
......@@ -7,7 +7,7 @@ import md5
import os
import re
import shutil
import urllib
from six.moves.urllib.parse import unquote
import zipfile
import fnmatch
......@@ -22,7 +22,7 @@ class FileBrowser(object):
self.config = config
def _realdir(self, dir):
realdir = realpath(self.config, urllib.unquote(dir))
realdir = realpath(self.config, unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
return realdir
......@@ -45,7 +45,7 @@ class FileBrowser(object):
"""List elements of directory 'dir' taken"""
html = 'var gsdirs = [], gsfiles = [];'
dir = urllib.unquote(dir)
dir = unquote(dir)
# XXX-Marco 'dir' and 'all' should not shadow builtin names
realdir = realpath(self.config, dir)
if not realdir:
......@@ -74,7 +74,7 @@ class FileBrowser(object):
return html
def fancylistDirs(self, dir, key, listfiles, all=False):
dir = urllib.unquote(dir)
dir = unquote(dir)
realdir = realpath(self.config, dir)
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
......@@ -125,7 +125,7 @@ class FileBrowser(object):
"""Delete a list of files or directories"""
# XXX-Marco do not shadow 'dir'
realdir = self._realdir(dir)
lfiles = urllib.unquote(files).split(',,,')
lfiles = unquote(files).split(',,,')
try:
# XXX-Marco do not shadow 'file'
for item in lfiles:
......@@ -147,7 +147,7 @@ class FileBrowser(object):
def copyItem(self, dir, files, del_source=False):
"""Copy a list of files or directory to dir"""
realdir = self._realdir(dir)
lfiles = urllib.unquote(files).split(',,,')
lfiles = unquote(files).split(',,,')
try:
# XXX-Marco do not shadow 'file'
for file in lfiles:
......@@ -174,7 +174,7 @@ class FileBrowser(object):
def rename(self, dir, filename, newfilename):
"""Rename file or directory to dir/filename"""
realdir = self._realdir(dir)
realfile = realpath(self.config, urllib.unquote(filename))
realfile = realpath(self.config, unquote(filename))
if not realfile:
raise NameError('Could not load directory %s: Permission denied' % filename)
tofile = os.path.join(realdir, newfilename)
......@@ -208,7 +208,7 @@ class FileBrowser(object):
def downloadFile(self, dir, filename):
"""Download file dir/filename"""
realdir = self._realdir(dir)
file = os.path.join(realdir, urllib.unquote(filename))
file = os.path.join(realdir, unquote(filename))
if not os.path.exists(file):
raise NameError('NOT ALLOWED OPERATION : File or directory does not exist %s'
% os.path.join(dir, filename))
......@@ -255,8 +255,8 @@ class FileBrowser(object):
def readFile(self, dir, filename, truncate=False):
"""Read file dir/filename and return content"""
realfile = realpath(self.config, os.path.join(urllib.unquote(dir),
urllib.unquote(filename)))
realfile = realpath(self.config, os.path.join(unquote(dir),
unquote(filename)))
if not realfile:
raise NameError('Could not load directory %s: Permission denied' % dir)
if not isText(realfile):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment