Commit 623d0201 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

wip

parent be91f152
......@@ -24,6 +24,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from __future__ import print_function
from slapos.recipe.librecipe import GenericBaseRecipe
import zc.buildout
import sys
......@@ -101,17 +103,17 @@ class Recipe(GenericBaseRecipe):
# TODO factor
if delete != []:
print "Creating lampconfigure with 'delete' arguments"
print("Creating lampconfigure with 'delete' arguments")
command = argument + delete
if rename != []:
for parameters in rename:
print "Creating lampconfigure with 'rename' arguments"
print("Creating lampconfigure with 'rename' arguments")
command = argument + rename
if chmod != []:
print "Creating lampconfigure with 'chmod' arguments"
print("Creating lampconfigure with 'chmod' arguments")
command = argument + chmod
if data != []:
print "Creating lampconfigure with 'run' arguments"
print("Creating lampconfigure with 'run' arguments")
command = argument + data
......
......@@ -24,6 +24,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from __future__ import print_function
from slapos.recipe.librecipe import GenericBaseRecipe
import os
import subprocess
......@@ -177,7 +179,7 @@ class Recipe(GenericBaseRecipe):
copyright=self.copyright, installroot=self.installroot))
)
path_list.append(sh_script)
os.chmod(bash , 0700)
os.chmod(bash , 0o700)
#After make_project run configure_script to perform and restart apache php services
service_status = os.path.join(self.home, '.start_service')
......@@ -234,9 +236,9 @@ class App(GenericBaseRecipe):
downloader = zc.buildout.download.Download(self.buildout['buildout'],
hash_name=True, cache=cache)
path, _ = downloader(param, md5sum=None)
mode = 0600
mode = 0o600
if key == 'binary':
mode = 0700
mode = 0o700
os.chmod(path, mode)
app[key] = path
......@@ -278,7 +280,7 @@ class App(GenericBaseRecipe):
if not current_app['template-result'] or not current_app['binary'] \
or not current_app['input-file'] or not current_app['template-wu'] \
or not current_app['platform']:
print "BOINC-APP: ERROR - Invalid argements values for % ...operation cancelled" % app
print("BOINC-APP: ERROR - Invalid argements values for % ...operation cancelled" % app)
app_list[app][version] = None
continue
#write application to install
......@@ -319,7 +321,7 @@ class App(GenericBaseRecipe):
dict(dash=self.options['dash'].strip()))
)
path_list.append(sh_script)
os.chmod(bash , 0700)
os.chmod(bash , 0o700)
#If useful, download necessary files and update options path
start_boinc = os.path.join(home, '.start_boinc')
......@@ -339,7 +341,7 @@ class App(GenericBaseRecipe):
platform = app_list[appname][version]['platform']
application = os.path.join(apps_dir, appname, version, platform)
if app_list[appname][version]['binary'] and not platform:
print "BOINC-APP: WARNING - Cannot specify binary without giving platform value"
print("BOINC-APP: WARNING - Cannot specify binary without giving platform value")
app_list[appname][version]['binary'] = '' #Binary will not be updated
parameter = dict(installroot=installroot,
......
......@@ -94,7 +94,7 @@ class Recipe(GenericBaseRecipe):
dict(ip_address=self.options['ipv6'].strip(),
project=project,
middleware=type)))
os.chmod(config_info_file, 0744)
os.chmod(config_info_file, 0o744)
path_list.append(config_info)
update = install
......
......@@ -26,11 +26,11 @@
##############################################################################
import os
import hashlib
import ConfigParser
from six.moves import configparser
import tempfile
from slapos.recipe.librecipe import GenericBaseRecipe
from certificate_authority import popenCommunicate
from .certificate_authority import popenCommunicate
class Recipe(GenericBaseRecipe):
......@@ -119,7 +119,7 @@ class Request(Recipe):
open(certificate, 'w').write(cert_content)
request_needed = False
else:
parser = ConfigParser.RawConfigParser()
parser = configparser.RawConfigParser()
parser.add_section('certificate')
parser.set('certificate', 'name', name)
parser.set('certificate', 'key_file', key)
......
from __future__ import print_function
import os
import subprocess
import time
import ConfigParser
from six.moves import configparser
import uuid
......@@ -95,12 +97,12 @@ class CertificateAuthority:
def checkRequestDir(self):
for request_file in os.listdir(self.request_dir):
parser = ConfigParser.RawConfigParser()
parser = configparser.RawConfigParser()
parser.readfp(open(os.path.join(self.request_dir, request_file), 'r'))
if self._checkCertificate(parser.get('certificate', 'name'),
parser.get('certificate', 'key_file'), parser.get('certificate',
'certificate_file')):
print 'Created certificate %r' % parser.get('certificate', 'name')
print('Created certificate %r' % parser.get('certificate', 'name'))
def runCertificateAuthority(*args):
ca = CertificateAuthority(*args)
......
......@@ -29,7 +29,6 @@ import os
import subprocess
import zc.buildout
import filecmp
import urlparse
import shutil
import re
import json
......@@ -130,9 +129,9 @@ class Recipe(GenericBaseRecipe):
#create condor binary launcher for slapos
if not os.path.exists(self.wrapper_bin):
os.makedirs(self.wrapper_bin, int('0744', 8))
os.makedirs(self.wrapper_bin, int('0o744', 8))
if not os.path.exists(self.wrapper_sbin):
os.makedirs(self.wrapper_sbin, int('0744', 8))
os.makedirs(self.wrapper_sbin, int('0o744', 8))
#generate script for each file in prefix/bin
for binary in os.listdir(self.prefix+'/bin'):
wrapper_location = os.path.join(self.wrapper_bin, binary)
......@@ -153,7 +152,7 @@ class Recipe(GenericBaseRecipe):
wrapper.write(content)
wrapper.close()
path_list.append(wrapper_location)
os.chmod(wrapper_location, 0744)
os.chmod(wrapper_location, 0o744)
#generate script for each file in prefix/sbin
for binary in os.listdir(self.prefix+'/sbin'):
......@@ -175,7 +174,7 @@ class Recipe(GenericBaseRecipe):
wrapper.write(content)
wrapper.close()
path_list.append(wrapper_location)
os.chmod(wrapper_location, 0744)
os.chmod(wrapper_location, 0o744)
#generate script for start condor
wrapper = self.createPythonScript(
......@@ -228,7 +227,7 @@ class AppSubmit(GenericBaseRecipe):
for file in file_list:
if file and (file.startswith('http') or file.startswith('ftp')):
file_list[file] = self.download(file_list[file])
os.chmod(file_list[file], 0600)
os.chmod(file_list[file], 0o600)
else:
app_list[app]['files'] = {}
......@@ -236,11 +235,11 @@ class AppSubmit(GenericBaseRecipe):
if executable and (executable.startswith('http') or executable.startswith('ftp')):
app_list[app]['executable'] = self.download(executable,
app_list[app]['executable-name'])
os.chmod(app_list[app]['executable-name'], 0700)
os.chmod(app_list[app]['executable-name'], 0o700)
submit_file = app_list[app].get('description-file', '')
if submit_file and (submit_file.startswith('http') or submit_file.startswith('ftp')):
app_list[app]['description-file'] = self.download(submit_file, 'submit')
os.chmod(app_list[app]['description-file'], 0600)
os.chmod(app_list[app]['description-file'], 0o600)
return app_list
......
......@@ -25,7 +25,7 @@
#
##############################################################################
import subprocess
import httplib
from six.moves import http_client as httplib
import base64
import os
import shutil
......
......@@ -29,6 +29,8 @@ import os
from slapos.recipe.librecipe import GenericBaseRecipe
from zc.buildout import UserError
from six.moves import map
class Recipe(GenericBaseRecipe):
def install(self):
......@@ -124,7 +126,7 @@ def systemd_to_cron(spec):
x = spec[i]
if x != '*':
for x in x.split(','):
x = map(int, x.split('/', 1))
x = list(map(int, x.split('/', 1)))
a = x[0] - y
if 0 <= a < z:
if len(x) == 1:
......
......@@ -26,7 +26,7 @@
##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe
import ConfigParser
from six.moves import configparser
class Recipe(GenericBaseRecipe):
"""
......@@ -34,7 +34,7 @@ class Recipe(GenericBaseRecipe):
"""
def install(self):
promise_parser = ConfigParser.RawConfigParser()
promise_parser = configparser.RawConfigParser()
for section_name, option_id_list in (
('portal_templates', (
('repository', 'bt5-repository-url'),
......
......@@ -24,10 +24,10 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import ConfigParser
from six.moves import configparser
import json
import os
import StringIO
import six
from slapos.recipe.librecipe import GenericBaseRecipe
......@@ -40,13 +40,13 @@ class Recipe(GenericBaseRecipe):
CONFIG['PATH'] = os.environ['PATH']
if self.options['instance-dict']:
config_instance_dict = ConfigParser.ConfigParser()
config_instance_dict = configparser.ConfigParser()
config_instance_dict.add_section('instance_dict')
instance_dict = json.loads(self.options['instance-dict'])
for k ,v in instance_dict.iteritems():
config_instance_dict.set('instance_dict', k, v)
value = StringIO.StringIO()
value = six.StringIO()
config_instance_dict.write(value)
CONFIG['instance_dict'] = value.getvalue()
......
......@@ -25,7 +25,7 @@
#
##############################################################################
import ConfigParser
from six.moves import configparser
import os
import netaddr
import socket
......@@ -48,7 +48,7 @@ class Recipe(object):
# If this check isn't done, a new port would be picked for every upgrade
# of the software release
try:
parser = ConfigParser.RawConfigParser()
parser = configPprser.RawConfigParser()
if os.path.exists(buildout['buildout']['installed']):
with open(buildout['buildout']['installed']) as config_file:
parser.readfp(config_file)
......@@ -59,7 +59,7 @@ class Recipe(object):
if port != '0':
self.options['port'] = port
return
except (IOError, ConfigParser.NoSectionError, ConfigParser.NoOptionError):
except (IOError, configparser.NoSectionError, configparser.NoOptionError):
pass
# Otherwise, let's find one
......
......@@ -31,7 +31,7 @@ import pkg_resources
import zc.buildout
import sys
import zc.recipe.egg
import urlparse
from six.moves.urllib import parse
# Warning : this recipe is deprecated and has been replaced by apachephp.
......@@ -264,7 +264,7 @@ class Request(BaseRecipe):
mysql = self.request(self.options['mariadb-software-url'],
software_type, 'MariaDB Server', partition_parameter_kw=parameters
).getConnectionParameter('url')
mysql_parsed = urlparse.urlparse(mysql)
mysql_parsed = parse.urlparse(mysql)
mysql_host, mysql_port = mysql_parsed.hostname, mysql_parsed.port
if mysql_parsed.scheme == 'mysqls': # Listen over stunnel
......
......@@ -57,7 +57,7 @@ class Recipe(BaseSlapRecipe):
try:
self.slave_partition_configuration_dict_list.append(
self._installSlavePartition(slave_partition))
except SlavePartitionError, e:
except SlavePartitionError as e:
self.logger.warning('Slave Parttion %r not installed, issue: %r'%(
slave_partition.getId(), e))
# Installs wrappers
......
from __future__ import print_function
import sys
import os
import signal
......@@ -5,6 +7,8 @@ import subprocess
from collections import defaultdict
from inotify_simple import INotify, flags
import six
def _wait_files_creation(file_list):
# Establish a list of directory and subfiles.
# and test existence before watching, so that we don't miss an event.
......@@ -14,7 +18,7 @@ def _wait_files_creation(file_list):
directories[dirname][filename] = os.path.lexists(f)
def all_files_exists():
return all(all(files.itervalues()) for files in directories.itervalues())
return all(all(six.itervalues(files)) for files in six.itervalues(directories))
with INotify() as inotify:
watchdescriptors = {inotify.add_watch(dirname,
......@@ -101,7 +105,7 @@ def generic_exec(args, extra_environ=None, wait_list=None,
child_pg = None
def sig_handler(sig, frame):
print 'Received signal %r, killing children and exiting' % sig
print('Received signal %r, killing children and exiting' % sig)
if child_pg is not None:
os.killpg(child_pg, signal.SIGHUP)
os.killpg(child_pg, signal.SIGTERM)
......@@ -116,7 +120,7 @@ def execute_with_signal_translation(args):
child = subprocess.Popen(args, close_fds=True, preexec_fn=os.setsid)
child_pg = child.pid
try:
print 'Process %r started' % (args, )
print('Process %r started' % (args, ))
signal.pause()
finally:
os.killpg(child_pg, signal.SIGHUP)
......
......@@ -34,7 +34,8 @@ import inspect
import re
import shutil
import urllib
from six import iteritems
import itertools
import six
from six.moves import map
from six.moves.urllib import parse
......@@ -131,9 +132,9 @@ class GenericBaseRecipe(object):
module, function = function
path, filename = os.path.split(os.path.abspath(name))
assert not isinstance(args, (basestring, dict)), args
args = map(repr, args)
args += map('%s=%r'.__mod__, kw.iteritems())
assert not isinstance(args, (six.string_types, dict)), args
args = itertools.chain(map(repr, args),
map('%s=%r'.__mod__, six.iteritems(kw)))
return zc.buildout.easy_install.scripts(
[(filename, module, function)], self._ws, sys.executable,
......@@ -156,7 +157,7 @@ class GenericBaseRecipe(object):
lines = ['#!/bin/sh']
if env:
for k, v in sorted(iteritems(env)):
for k, v in sorted(six.iteritems(env)):
lines.append('export %s=%s' % (k, shlex.quote(v)))
lines.append('exec')
......
......@@ -25,6 +25,8 @@
#
##############################################################################
from __future__ import print_function
import sys
import pkg_resources
from logging import Formatter
......@@ -41,7 +43,7 @@ class NoSQLTestBed(BaseSlapRecipe):
testbed = plugin_class()
except:
print Formatter().formatException(sys.exc_info())
print(Formatter().formatException(sys.exc_info()))
return None
software_type = self.parameter_dict.get('slap_software_type', 'default')
......
......@@ -25,12 +25,14 @@
#
##############################################################################
from __future__ import print_function
import json
import os
import subprocess
import sys
import textwrap
import urlparse
from six.moves.urllib import parse
from slapos.recipe.librecipe import GenericSlapRecipe
from slapos.recipe.dropbear import KnownHostsFile
......@@ -208,7 +210,7 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
# This behavior has been removed to accelerate deployment of the
# Software Release. The buildout, instead of failing, can process
# other sections, which will return parameters to the main instance faster
parsed_url = urlparse.urlparse(url)
parsed_url = parse.urlparse(url)
slave_type = entry['type']
if not slave_type in ['pull', 'push']:
......@@ -216,7 +218,7 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
slave_id = entry['notification-id']
print 'Processing PBS slave %s with type %s' % (slave_id, slave_type)
print('Processing PBS slave %s with type %s' % (slave_id, slave_type))
path_list.append(self.createPythonScript(
os.path.join(self.options['promises-directory'], "ssh-to-%s" % slave_id),
......
......@@ -25,7 +25,7 @@
#
##############################################################################
import md5
import hashlib
import os
import subprocess
import textwrap
......@@ -195,7 +195,7 @@ class Recipe(GenericBaseRecipe):
password = self.options['password']
# encrypt the password to avoid storing in the logs
enc_password = 'md5' + md5.md5(password+user).hexdigest()
enc_password = 'md5' + hashlib.md5(password+user).hexdigest()
self.runPostgresCommand(cmd="""ALTER USER "%s" ENCRYPTED PASSWORD '%s'""" % (user, enc_password))
......
......@@ -81,5 +81,5 @@ def promise(host, port, unixsocket):
r = Redis(host=host, port=port, unix_socket_path=unixsocket, db=0)
r.publish("Promise-Service","SlapOS Promise")
r.connection_pool.disconnect()
except Exception, e:
except Exception as e:
sys.exit(e)
......@@ -33,6 +33,8 @@ from slapos.slap import SoftwareProductCollection
import slapos.recipe.librecipe.generic as librecipe
import traceback
import six
SOFTWARE_PRODUCT_NAMESPACE = "product."
DEFAULT_SOFTWARE_TYPE = 'RootSoftwareInstance'
......@@ -110,10 +112,10 @@ class Recipe(object):
raise UserError("'config' & 'sla' options are obsolete."
" Clean up your software release.")
filter_kw = {k[4:]: v
for k, v in options.iteritems()
for k, v in six.iteritems(options)
if k.startswith('sla-') and v}
partition_parameter_kw = self._filterForStorage({k[7:]: v
for k, v in options.iteritems()
for k, v in six.iteritems(options)
if k.startswith('config-')})
slave = options.get('slave', 'false').lower() in \
librecipe.GenericBaseRecipe.TRUE_VALUES
......@@ -310,12 +312,12 @@ class RequestEdge(Recipe):
self.request_dict[country] = Recipe(buildout, name, local_options)
# "Bubble" all connection parameters
for option, value in local_options.iteritems():
for option, value in six.iteritems(local_options):
if option.startswith(CONNECTION_PARAMETER_STRING):
self.options['%s-%s' % (option, country)] = value
def install(self):
for country, request in self.request_dict.iteritems():
for country, request in six.iteritems(self.request_dict):
request.install()
return []
......
......@@ -26,8 +26,6 @@
##############################################################################
import os
import urllib
import urllib2
import pkg_resources
from slapos.recipe.librecipe import BaseSlapRecipe
......
......@@ -36,7 +36,7 @@ def kill(pid_file, sig=signal.SIGUSR1):
pid = int(f.read().strip())
try:
os.kill(pid, sig)
except OSError, e:
except OSError as e:
if e.errno != errno.ESRCH: # No such process
raise e
os.unlink(pid_file)
......
......@@ -69,7 +69,7 @@ export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"
bindir = os.path.join(tomcat_home, 'bin')
for f in os.listdir(bindir):
if f.endswith('.sh'):
os.chmod(os.path.join(bindir, f), 0755)
os.chmod(os.path.join(bindir, f), 0o755)
tomcat_wrapper = self.createRunningWrapper('xwiki', """#!/bin/sh
export JRE_HOME=%(java_home)s
exec %(catalina)s run
......
......@@ -33,7 +33,6 @@ import hashlib
import sys
import zc.buildout
import zc.recipe.egg
import ConfigParser
class Recipe(BaseSlapRecipe):
def installLogrotate(self):
......
......@@ -22,7 +22,7 @@ class PBSTest(unittest.TestCase):
def test_push(self):
recipe = self.new_recipe()
with tempfile.NamedTemporaryFile() as rdiff_wrapper:
with tempfile.NamedTemporaryFile('w+') as rdiff_wrapper:
recipe.wrapper_push(remote_schema='TEST_REMOTE_SCHEMA',
local_dir='TEST_LOCAL_DIR',
remote_dir='TEST_REMOTE_DIR',
......@@ -35,7 +35,7 @@ class PBSTest(unittest.TestCase):
def test_pull(self):
recipe = self.new_recipe()
with tempfile.NamedTemporaryFile() as rdiff_wrapper:
with tempfile.NamedTemporaryFile('w+') as rdiff_wrapper:
recipe.wrapper_pull(remote_schema='TEST_REMOTE_SCHEMA',
local_dir='TEST_LOCAL_DIR',
remote_dir='TEST_REMOTE_DIR',
......
......@@ -2,7 +2,7 @@
"""
import sys
import os.path
from ConfigParser import ConfigParser
from six.moves.configparser import ConfigParser
import logging
......
......@@ -38,5 +38,3 @@ netifaces = 0.10.7
supervisor =
xml-marshaller = 0.9.7+SlapOSPatched001
slapos.recipe.build = 0.38
pyOpenSSL = 18.0.0
cryptography = 2.3.1
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