fixed print statements to be in python3

This commit is contained in:
Ronny Abraham 2018-10-17 22:48:54 +03:00
parent 33b11f3df8
commit a97698ae9a
14 changed files with 141 additions and 139 deletions

View file

@ -263,11 +263,11 @@ class DeployMeta(QtGui.QMainWindow):
def load_config(self, configname):
if configname not in self.CONFIG_TYPES.keys():
print "\nerror, load_config was called with parameter: {confname}," \
"which is not a legitimate value in CONFIG TYPES." \
"\nLegitimate values are {configvalues}".format(
confname=configname,
configvalues=self.CONFIG_TYPES.keys())
print("\nerror, load_config was called with parameter: {confname},"
"which is not a legitimate value in CONFIG TYPES."
"\nLegitimate values are {configvalues}".format(
confname=configname,
configvalues=self.CONFIG_TYPES.keys()))
sys.exit()
path_config_full = os.path.join(
@ -417,7 +417,7 @@ class DeployMeta(QtGui.QMainWindow):
" default config types")
retval = msg.exec_()
print "value of qmessagebox in action_save: %s" % retval
print("value of qmessagebox in action_save: %s" % retval)
def setupMenu(self):
menubar = self.menuBar()
@ -482,7 +482,7 @@ def main():
ex = DeployMeta()
sys.exit(app.exec_())
print ex
print(ex)
if __name__ == '__main__':

View file

@ -10,8 +10,8 @@ parser.add_argument('--file2', default='test.yml')
def findDiff(d1, d2, path=""):
for k in d1.keys():
if not (k in d2):
print path, ":"
print k + " as key not in d2", "\n"
print(path, ":")
print(k + " as key not in d2", "\n")
else:
if type(d1[k]) is dict:
if path == "":
@ -21,9 +21,9 @@ def findDiff(d1, d2, path=""):
findDiff(d1[k], d2[k], path)
else:
if d1[k] != d2[k]:
print path, ":"
print " - ", k, " : ", d1[k]
print " + ", k, " : ", d2[k]
print(path, ":")
print(" - ", k, " : ", d1[k])
print(" + ", k, " : ", d2[k])
def compare_dictionaries(dict_1, dict_2, dict_1_name, dict_2_name, path=""):
@ -85,6 +85,6 @@ def main():
yaml_test = ruamel.yaml.load(file(path_test, 'r'))
a = compare_dictionaries(yaml_main, yaml_test, 'main', 'test')
print a
print(a)
main()

6
fabfile.py vendored
View file

@ -17,7 +17,7 @@ branch = "development"
def setup():
print "setup fabric configuration files"
print("setup fabric configuration files")
def all():
@ -48,7 +48,7 @@ def stage():
global branch
branch = "staging"
print "in staging"
print("in staging")
all()
@ -62,7 +62,7 @@ def prod():
global branch
branch = "production"
print "in production"
print("in production")
all()

View file

@ -11,7 +11,7 @@ def deploy(param=None):
param_list = ['conf', 'readmes']
if not param:
print "this requires input param must be one of %s" % param_list
print("this requires input param must be one of %s" % param_list)
import sys
sys.exit()
@ -26,7 +26,7 @@ def backup(param=None):
param_list = ['conf', 'meta', 'readmes']
if not param:
print "this requires input param must be one of %s" % param_list
print("this requires input param must be one of %s" % param_list)
import sys
sys.exit()
@ -308,6 +308,6 @@ def edit(param='help'):
"""
for k_loc in locations.keys():
print "\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc'])
print("\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc']))
return

View file

@ -31,7 +31,7 @@ Error. maintenance.exists_dir_sub takes a 'section' parameter value.
Valid options include:""" % section
for key in configuration.templates.keys():
print " %s" % key
print(" %s" % key)
print """
Please run the command again, but this time enter a valid section value.
@ -54,8 +54,8 @@ def exists_dir_top():
# located files, since those files get rsync'd anyway.
if env.debug:
print "maintenance.exists_dir_top -- checking for " \
"directory:\n\t%s\n" % configuration.paths.conf.local
print("maintenance.exists_dir_top -- checking for "
"directory:\n\t%s\n" % configuration.paths.conf.local)
return exists(configuration.paths.conf.local)

View file

@ -78,7 +78,7 @@ def generate_sql(script_name):
# with open(build_path, "w") as output:
# output.write(rendered)
print NOTE
print(NOTE)
def execute_sql(script_name, add_dbname=True, is_admin=False):
@ -121,7 +121,7 @@ def execute_sql(script_name, add_dbname=True, is_admin=False):
else:
run_database_command(psql_command, user)
print NOTE
print(NOTE)
@task
@ -138,7 +138,7 @@ def generate():
@task
def clear_scripts():
print "this does nothing, the code isn't here"
print("this does nothing, the code isn't here")
@task
@ -200,7 +200,7 @@ def commandline(dbuser='default'):
host = configuration.server.database.host
port = configuration.server.database.port
print "debug -- dbuser: %s" % dbuser
print("debug -- dbuser: %s" % dbuser)
if dbuser == 'admin':
user = configuration.server.database.admin.user
@ -222,7 +222,7 @@ def commandline(dbuser='default'):
user=user
)
print "debug -- cmd_commandline: %s" % cmd_commandline
print("debug -- cmd_commandline: %s" % cmd_commandline)
run_database_command(cmd_commandline, user)
@ -270,7 +270,7 @@ def backup(dbuser='default', backup_file=None, branch=None,
timefilename = os.path.join(
configuration.paths.server.backups.database,
backup_file_time)
print "debug timefilename -- %s" % timefilename
print("debug timefilename -- %s" % timefilename)
dumpfilename = os.path.join(
configuration.paths.server.backups.database,
@ -278,7 +278,7 @@ def backup(dbuser='default', backup_file=None, branch=None,
datadump_only = booleanize(datadump_only)
print "dumpfilename: %s" % dumpfilename
print("dumpfilename: %s" % dumpfilename)
if not datadump_only:
@ -307,7 +307,7 @@ def backup(dbuser='default', backup_file=None, branch=None,
hide_output = False
print "cmd_pg_dump: %s" % cmd_pg_dump
print("cmd_pg_dump: %s" % cmd_pg_dump)
output = run_database_command(cmd_pg_dump, user, hide=hide_output)
@ -349,7 +349,7 @@ def restore(dbuser='default', backup_file=None, reinitialize=True):
timefilename = os.path.join(
configuration.paths.server.backups.database,
backup_file_time)
print "debug -- timefilename: %s" % timefilename
print("debug -- timefilename: %s" % timefilename)
dumpfilename = os.path.join(
configuration.paths.server.backups.database,
@ -390,26 +390,26 @@ def sync(src):
configuration_src = initialize.environment(branch_src)
configuration_dst = configuration
print "branch_src: %s" % configuration_src.project.branch
print "branch_dst: %s" % configuration_dst.project.branch
print("branch_src: %s" % configuration_src.project.branch)
print("branch_dst: %s" % configuration_dst.project.branch)
# backup all files with names that wont interfere
output_name_dst = "output_sync_dst.sql"
backup_name_dst = "backup_sync_dst.sql"
backup_name_src = "backup_sync_src.sql"
print "output_src = backup("
print "\tbackup_file=%s," % backup_name_src
print "\tbranch=%s)" % configuration_src.project.branch
print("output_src = backup(")
print("\tbackup_file=%s," % backup_name_src)
print("\tbranch=%s)" % configuration_src.project.branch)
# dump the source database to our {destination}/backups/database
print "backup up src: %s" % configuration_src.project.branch
print("backup up src: %s" % configuration_src.project.branch)
output_src = backup(
backup_file=backup_name_src,
branch=configuration_src.project.branch)
print "backing up dst: %s" % configuration_dst.project.branch
print("backing up dst: %s" % configuration_dst.project.branch)
backup(
backup_file=backup_name_dst,
branch=configuration_dst.project.branch)
@ -492,8 +492,8 @@ def get_template_path(script_name, script_type):
'files',
file_template)
else:
print "Error, you passed the variable %s, must pass" \
"either 'build' or 'template'" % script_type
print("Error, you passed the variable %s, must pass"
"either 'build' or 'template'" % script_type)
import sys
sys.exit()
@ -565,7 +565,8 @@ def edit(param='help'):
"""
for k_loc in locations.keys():
print "\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc'])
print("\t{0: <20} - {1}".format(
k_loc, locations[k_loc]['desc']))
return

View file

@ -378,31 +378,31 @@ def sync(full=True, extras=False):
"build/*", "/extras", "/opt")
if env.debug:
print "\n%s debug: %s" % (debug_prefix, env.debug)
print("\n%s debug: %s" % (debug_prefix, env.debug))
print "\n%s project.name %s" \
% (debug_prefix, configuration.project.name)
print("\n%s project.name %s" %
(debug_prefix, configuration.project.name))
print "%s project.branch %s" \
% (debug_prefix, configuration.project.branch)
print("%s project.branch %s" %
(debug_prefix, configuration.project.branch))
print "%s path.project %s" \
% (debug_prefix, configuration.paths.project.root)
print("%s path.project %s" %
(debug_prefix, configuration.paths.project.root))
print "\n%s run(%s)" % (debug_prefix, command_mkdir_remote)
print("\n%s run(%s)" % (debug_prefix, command_mkdir_remote))
print "\n{debug_prefix} rsync_project(\n\tremote_dir={remote_dir}," \
"\n\tlocal_dir={local_dir},\n\texclude={excludeitems})".format(
debug_prefix=debug_prefix,
remote_dir=remote_dir,
local_dir=local_dir,
excludeitems=excludeitems)
print("\n{debug_prefix} rsync_project(\n\tremote_dir={remote_dir},"
"\n\tlocal_dir={local_dir},\n\texclude={excludeitems})".format(
debug_prefix=debug_prefix,
remote_dir=remote_dir,
local_dir=local_dir,
excludeitems=excludeitems))
# print "\n%s override: %s " \
# % (debug_prefix, configuration.overrides.keys())
# print("\n%s override: %s " %
# (debug_prefix, configuration.overrides.keys()))
# print "%s has overrides? %s" \
# % (debug_prefix, (len(configuration.overrides.keys()) > 0))
# print("%s has overrides? %s" %
# (debug_prefix, (len(configuration.overrides.keys()) > 0)))
else:
@ -442,8 +442,8 @@ def sync(full=True, extras=False):
return
# print "remote_dir: %s" % remote_dir
# print "local_dir: %s" % local_dir
# print("remote_dir: %s" % remote_dir)
# print("local_dir: %s" % local_dir)
# import sys
# sys.exit()
@ -486,7 +486,7 @@ def media(source_branch):
import initialize
print "project.branch: %s" % configuration.project.branch
print("project.branch: %s" % configuration.project.branch)
#
# if we use initialize.environemnt, we will overwrite all project
@ -495,13 +495,14 @@ def media(source_branch):
configuration_src = initialize.get_config(source_branch)
configuration_dst = configuration
print "branch_src: %s" % configuration_src.project.branch
print "branch_dst: %s" % configuration_dst.project.branch
print("branch_src: %s" % configuration_src.project.branch)
print("branch_dst: %s" % configuration_dst.project.branch)
print "src - server_media_dynamic: %s" % \
configuration_src.paths.server.media.dynamic
print "dst - server_media_dynamic: %s" % \
configuration_dst.paths.server.media.dynamic
print("src - server_media_dynamic: %s" %
configuration_src.paths.server.media.dynamic)
print("dst - server_media_dynamic: %s" %
configuration_dst.paths.server.media.dynamic)
# add a trailing slash to the directories
dynamic_src = "%s/" % configuration_src.paths.server.media.dynamic
@ -532,7 +533,7 @@ def media(source_branch):
path_dst=dynamic_dst,
)
print cmd_rsync
print(cmd_rsync)
upstream = True
remote_dir = dynamic_dst
@ -548,30 +549,30 @@ def media(source_branch):
#
# rsync relies on env.host_string to determine what the username and
# host is
# print "before: %s" % env.host_string
# print("before: %s" % env.host_string)
# configuration_dst = initialize.environment(source_branch)
# print "after: %s" % env.host_string
# print("after: %s" % env.host_string)
# import sys
# sys.exit()
print "upstream: %s" % upstream
print "remote_dir: %s" % remote_dir
print "local_dir: %s" % local_dir
print "\ncopy from {src} to {dst}\n".format(
print("upstream: %s" % upstream)
print("remote_dir: %s" % remote_dir)
print("local_dir: %s" % local_dir)
print("\ncopy from {src} to {dst}\n".format(
src=configuration_src.project.host,
dst=configuration_dst.project.host)
dst=configuration_dst.project.host))
elif configuration_dst.project.host == "localhost":
remote_dir = dynamic_src
local_dir = dynamic_dst
upstream = False
print "upstream: %s" % upstream
print "remote_dir: %s" % remote_dir
print "local_dir: %s" % local_dir
print "\ncopy from {src} to {dst}\n".format(
print("upstream: %s" % upstream)
print("remote_dir: %s" % remote_dir)
print("local_dir: %s" % local_dir)
print("\ncopy from {src} to {dst}\n".format(
src=configuration_src.project.host,
dst=configuration_dst.project.host)
dst=configuration_dst.project.host))
else:
print_console("no moving media files from staging to production")
return
@ -582,7 +583,7 @@ def media(source_branch):
local_dir=local_dir,
upstream=upstream)
print cmd_msg
print(cmd_msg)
from fabric.contrib.project import rsync_project
rsync_project(remote_dir=remote_dir,
@ -597,9 +598,9 @@ def test():
projectpath = configuration.paths.project.root
local_dir = configuration.paths.project.local + "/"
print hasattr(configuration, 'docker')
print "project path : %s" % projectpath
print "local dir : %s" % local_dir
print(hasattr(configuration, 'docker'))
print("project path : %s" % projectpath)
print("local dir : %s" % local_dir)
@task

View file

@ -31,8 +31,8 @@ def generate_secret_key():
@task
def test(args=None):
print "debug - testing checkapp(sorl.thumbnail): %s" % \
check_app("sorl.thumbnail")
print("debug - testing checkapp(sorl.thumbnail): %s" %
check_app("sorl.thumbnail"))
@task
@ -48,7 +48,7 @@ def commandline(args=""):
args=args,
djangosettings=configuration.imports.settings,)
print commandline
print(commandline)
@task
@ -174,8 +174,8 @@ def installed_apps():
"""
configuration = env.config
printecho = "print '\\n'"
printcommand = "print '\\n'.join([ item for item" \
printecho = "print('\\n')"
printcommand = "print('\\n').join([ item for item" \
" in {settings}.INSTALLED_APPS])".format(
settings=configuration.imports.settings)
@ -354,29 +354,29 @@ def generate_scripts(template_name, make_copy=False):
fabric_ops.run(copy_cmd)
print "\n\n------------------------------"
print "project_name : %s" % project_name
print "project_branch : %s" % project_branch
print "project_path : %s" % project_path
print "template_name : %s" % template_name
print "build_path : %s" % build_path
print "files_path : %s" % files_path
print "files_name : %s" % files_name
print("\n\n------------------------------")
print("project_name : %s" % project_name)
print("project_branch : %s" % project_branch)
print("project_path : %s" % project_path)
print("template_name : %s" % template_name)
print("build_path : %s" % build_path)
print("files_path : %s" % files_path)
print("files_name : %s" % files_name)
print "copy_path : %s" % copy_path
print "copy_full_path : %s" % copy_full_path
print "build_name : %s" % build_name
print("copy_path : %s" % copy_path)
print("copy_full_path : %s" % copy_full_path)
print("build_name : %s" % build_name)
upload_msg = utils_upload_template(
filename=files_name, destination=build_path, context=context,
use_jinja=True, use_sudo=False, backup=True,
template_dir=files_path, debug=True)
print "upload_msg : %s" % upload_msg
print "make_copy : %s" % make_copy
print "copy_cmd : %s" % copy_cmd
print "backup_cmd : %s" % backup_cmd
print "------------------------------\n\n"
print("upload_msg : %s" % upload_msg)
print("make_copy : %s" % make_copy)
print("copy_cmd : %s" % copy_cmd)
print("backup_cmd : %s" % backup_cmd)
print("------------------------------\n\n")
@task
@ -524,12 +524,12 @@ def generate_gunicorn(make_link=True):
template_dir=files_path)
if make_link:
print "\nlinking the generating gunicorn file in conf to " \
"the server diretory\n"
print("\nlinking the generating gunicorn file in conf to "
"the server diretory\n")
fabric_ops.run(msg_link_gunicorn)
else:
print "\nNOTE: not linking the generated gunicorn file" \
"to the server directory\n"
print("\nNOTE: not linking the generated gunicorn file"
"to the server directory\n")
@task
@ -610,7 +610,7 @@ def edit(param='help'):
"""
for k_loc in locations.keys():
print "\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc'])
print("\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc']))
return
@ -669,7 +669,7 @@ def clearmigrations(appname="help"):
@task
def makemigrations_empty(param="help"):
if param == "help":
print "print this help message"
print("print this help message")
return
manage("makemigrations --empty %s" % param)
@ -686,14 +686,14 @@ def fixtures(appname=None, backup=False):
# booleanize the backup parameter
backup = booleanize(backup)
print "debug - appname: %s" % appname
print("debug - appname: %s" % appname)
# from fabric.api import *
path_data = configuration.paths.django.fixtures
path_backup = configuration.paths.server.backups.fixtures
print "debug - path_backup: %s" % path_backup
print("debug - path_backup: %s" % path_backup)
if appname is not None:
path_data = os.path.join(path_data, appname)
@ -710,7 +710,7 @@ def fixtures(appname=None, backup=False):
else:
path_fixture = os.path.join(path_data, fixture_name)
print "debug - path_fixture: %s" % path_fixture
print("debug - path_fixture: %s" % path_fixture)
from utils import ensure_dir
ensure_dir(path_data)
@ -760,7 +760,7 @@ def loaddata(param=None):
configuration = env.config
if param is None:
print "you must specify an appname to load the fixture to"
print("you must specify an appname to load the fixture to")
return
else:
appname = param

View file

@ -101,7 +101,7 @@ def generate():
import pprint
pp = pprint.PrettyPrinter(indent=4)
print "context:\n"
print("context:\n")
pp.pprint(context)
else:
@ -176,7 +176,7 @@ def start(create=False):
configuration.docker.database.container_name
if env.debug:
print "docker_run(%s)" % docker_start
print("docker_run(%s)" % docker_start)
else:
docker_run(docker_start)
@ -202,8 +202,8 @@ def stop(remove=False):
docker_rm = 'docker rm %s' % configuration.docker.database.container_name
if env.debug:
print "docker_run(%s)" % docker_stop
print "docker_run(%s)" % docker_rm
print("docker_run(%s)" % docker_stop)
print("docker_run(%s)" % docker_rm)
else:
docker_run(docker_stop)

View file

@ -359,7 +359,7 @@ def get_config(branchname):
dataobject.server.nginx.port = config['nginx']['port']
dataobject.server.nginx.socket = config['nginx']['socket']
print "DEBUG -- socket: %s" % dataobject.server.nginx.socket
print("DEBUG -- socket: %s" % dataobject.server.nginx.socket)
if config['project']['host'] == "localhost":
dataobject.server.nginx.host = "{projectname}.{ext}".format(
@ -426,9 +426,9 @@ def get_config(branchname):
if 'database' in config['docker']:
add_template(dataobject, layout, config, "docker", "database")
else:
print "NOTE: docker.database does not exist for this branch"
print("NOTE: docker.database does not exist for this branch")
else:
print "NOTE: docker information does not exist for this branch"
print("NOTE: docker information does not exist for this branch")
#
# nginx information

View file

@ -22,19 +22,19 @@ def command(program=None, cmd=None, extra_param=None):
# logger = loggify('maintenance', 'command')
if program is None:
print "Error: You have not given a legitimate program"
print("Error: You have not given a legitimate program")
print "permissable programs : %s" \
% configuration.maintenance.keys()
print("permissable programs : %s" %
configuration.maintenance.keys())
sys.exit()
configuration_program = getattr(configuration.maintenance, program)
if cmd is None:
print "Error: You have not given a legitimate command"
print "permissable commands : %s" \
% configuration_program.commands.keys()
print("Error: You have not given a legitimate command")
print("permissable commands : %s" %
configuration_program.commands.keys())
sys.exit()
@ -165,8 +165,8 @@ def _get_configuration_path(name, branch):
param_list = ['config', 'layout']
if name not in param_list:
print "value %s was not legit. _get_configuration_path requires" \
"value such from %s" % (name, param_list)
print("value %s was not legit. _get_configuration_path requires"
"value such from %s" % (name, param_list))
META_DIR = os.path.join(
get_project_root(), 'usr', 'meta', 'project')

View file

@ -221,8 +221,8 @@ def copyto(branch):
configuration.virtualenv.requirements.local,
branch_config.virtualenv.requirements.filename)
print "current_local_path: %s" % current_local_path
print "branch_local_path: %s" % branch_local_path
print("current_local_path: %s" % current_local_path)
print("branch_local_path: %s" % branch_local_path)
message = "Copying file from current branch '{branch_src}' to " \
"destination branch '{branch_dst}'. Continue? Y/n ".format(

View file

@ -47,7 +47,7 @@ def command(cmd=None):
param = _initialize(configuration)
if cmd == "update":
print "in update"
print("in update")
# we don't need to specify the supervisor configuration file name, because
# supervisor can figure it out. ie whatever.conf is referred to by

View file

@ -11,7 +11,7 @@ from fabric.operations import run, sudo
def printvar(name, value, exit=False):
print "%s : %s" % (name, value)
print("%s : %s" % (name, value))
if exit:
sys.exit()
@ -88,8 +88,7 @@ def print_console(string, prepend="\n\n", append="\n\n", sep="-", numsep=44):
def print_debug(debugstr, module, function):
print "%s:%s:%s" \
% (module, function, debugstr)
print("%s:%s:%s" % (module, function, debugstr))
def executize(config_execute):
@ -146,12 +145,13 @@ def ensure_dir(directory):
"""
try:
if not os.path.exists(directory):
print "creating directory: %s" % directory
print("creating directory: %s" % directory)
os.makedirs(directory)
except OSError, e:
if e.errno != errno.EEXIST:
print "Error occurred while creating directory: %s" % directory
print("Error occurred while creating directory: %s"
% directory)
raise