def setup_ssh(): """Uploads ssh from the local folder specified in config.""" user = cget("user") ssh_target_dir = cget("ssh_target") # Ensure SSH directory is created with proper perms. create_target_directories([ssh_target_dir], "700", user) # Upload SSH config and keys. # TODO: Add copying files from remote folder (upload_ssh_keys_from_local). if cget('upload_ssh_keys_from_local') or True: files = cget('ssh_files') if not files: show(yellow("No SSH files to upload.")) return show(yellow("Uploading SSH configuration and keys")) for name in files: show(u"File: {0}".format(name)) local_path = pjoin(local_files_dir("ssh"), name) remote_path = pjoin(ssh_target_dir, name) put_file_with_perms(local_path, remote_path, "600", user, user) else: # Remoty copying of files raise Exception('Not implemented!' ' Please set upload_ssh_keys_from_local to True!')
def upload_settings_files(): """Uploads target specific (templated) settings files. If specified also uploads user supplied locals.py. *Warning*: Settings are uploaded from your local template file. Make sure to have proper branch/revision checked out. """ base_dir = cget("base_dir") user = cget("user") locals_path = cget("locals_path") show(yellow("Uploading Django settings files.")) # This is Template context not the deployment context. # A split should happen some time. context = dict(env["ctx"]) context # Upload main settings and ensure permissions. source = pjoin(local_files_dir("django"), "settings_template.py") destination = pjoin(base_dir, "settings", "%s.py" % cget("settings_name")) upload_template_with_perms(source, destination, context, mode="644", user=user, group=user) # We could be deploying from different directory. # Try our best to find correct path. # First - direct, absolute match. if not os.path.isfile(locals_path): # Try relative to deployment directory. this_dir = os.path.dirname(os.path.abspath(__file__)) locals_path = pjoin(this_dir, locals_path) if not os.path.isfile(locals_path): # :(( msg = u"Warning: Specified local settings path is incorrect: {0}." show(red(msg.format(locals_path))) confirm_or_abort(red("\nDo you want to continue?")) locals_path = None # Upload user supplied locals if present. if locals_path: show(yellow("Uploading your custom local settings files.")) destination = pjoin(base_dir, "settings", "local.py") put_file_with_perms(locals_path, destination, mode="644", user=user, group=user)
def setup_ssh(): """Uploads ssh from the local folder specified in config.""" user = cget("user") ssh_target_dir = cget("ssh_target") # Ensure SSH directory is created with proper perms. create_target_directories([ssh_target_dir], "700", user) # Upload SSH config and keys. # TODO: Add copying files from remote folder (upload_ssh_keys_from_local). if cget('upload_ssh_keys_from_local') or True: files = cget('ssh_files') show(yellow("Uploading SSH configuration and keys")) for name in files: show(u"File: {0}".format(name)) local_path = pjoin(local_files_dir("ssh"), name) remote_path = pjoin(ssh_target_dir, name) put_file_with_perms(local_path, remote_path, "600", user, user) else: # Remoty copying of files raise Exception('Not implemented!' ' Please set upload_ssh_keys_from_local to True!')
def upload_settings_files(): """Uploads target specific (templated) settings files. If specified also uploads user supplied locals.py. *Warning*: Settings are uploaded from your local template file. Make sure to have proper branch/revision checked out. """ base_dir = cget("base_dir") user = cget("user") locals_path = cget("locals_path") show(yellow("Uploading Django settings files.")) # This is Template context not the deployment context. # A split should happen some time. context = dict(env["ctx"]) context # Upload main settings and ensure permissions. # source = pjoin(local_files_dir("django"), "settings_template.py") # destination = pjoin(base_dir, "settings", "%s.py" % cget("settings_name")) # upload_template_with_perms(source, destination, context, mode="644", # user=user, group=user) # We could be deploying from different directory. # Try our best to find correct path. # First - direct, absolute match. if not locals_path: return if not os.path.isfile(locals_path): # Try relative to deployment directory. this_dir = os.path.dirname(os.path.abspath(__file__)) locals_path = pjoin(this_dir, locals_path) if not os.path.isfile(locals_path): # :(( msg = u"Warning: Specified local settings path is incorrect: {0}." show(red(msg.format(locals_path))) confirm_or_abort(red("\nDo you want to continue?")) locals_path = None # Upload user supplied locals if present. if locals_path: show(yellow("Uploading your custom local settings files.")) destination = pjoin(base_dir, "settings", "local.py") put_file_with_perms(locals_path, destination, mode="644", user=user, group=user) # Upload Google Prediction credentials this_dir = os.path.dirname(os.path.abspath(__file__)) cred_file = pjoin(this_dir, '..', 'prediction.dat') base_dir = cget('project_dir') if os.path.isfile(cred_file): show(yellow("Uploading Google Prediction credentials storage.")) destination = pjoin(base_dir, 'code', 'prediction.dat') # Main project directory show(yellow("Uploading to %s." % destination)) put_file_with_perms(cred_file, destination, mode="644", user=user, group=user) # Classification module destination = pjoin(base_dir, 'code', 'urlannotator', 'classification', 'prediction.dat') show(yellow("Uploading to %s." % destination)) put_file_with_perms(cred_file, destination, mode="644", user=user, group=user)