Commit 59ee2f81 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

wip

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