def git_install(self, local_directory, repository, install_commands, branch='master', configure_options=None, make_options=None): get_terminal_screen() git_exec = find('git') system('%s clone %s --single-branch --branch %s %s' % (git_exec, repository, branch, local_directory)) chdir(local_directory) for cmd in install_commands: if cmd == './configure' and configure_options is not None: res = system(cmd + ' ' + configure_options) elif cmd == 'make' and make_options is not None: res = system(cmd + ' ' + make_options) else: res = system(cmd) if res != 0: sleep(2) raise Exception('Executing install command \'%s\' failed' % cmd) exec_path = '%s/%s' % (self.install_dir, TARGETS[self.current_target]['rel_path']) if exists(exec_path): self.config.set('TARGETS', self.current_target, exec_path)
def build_ember_project(): import subprocess as sp from distutils.spawn import find_executable as find project_dir = os.path.join(".", "snf-ui") if not os.path.exists(project_dir): os.mkdir(project_dir) setupdir = os.getcwd() os.chdir(project_dir) env = os.environ.get('SNFUI_AUTO_BUILD_ENV', 'production') cache_args = "--cache-min 99999999" if not find("npm"): raise Exception("NPM not found please install nodejs and npm") if not os.path.exists("./node_modules"): print "Install np[m dependencies" cmd = "npm install --silent " + cache_args ret = sp.call(cmd, shell=True) if ret == 1: raise Exception("ember install failed") ember_bin = "./node_modules/ember-cli/bin/ember" if not os.path.exists(ember_bin): print "Installing ember-cli..." cmd = "npm install ember-cli --silent " + cache_args sp.call(cmd, shell=True) bower_bin = "bower" if find("bower") is None: bower_bin = "./node_modules/bower/bin/bower" if not os.path.exists(bower_bin): print "Installing bower..." cmd = "npm install bower --silent " + cache_args sp.call(cmd, shell=True) if not os.path.exists("./bower_components"): print "Install bower dependencies" cmd = "%s install --allow-root --quiet" % bower_bin ret = sp.call(cmd, shell=True) if ret == 1: raise Exception("bower install failed") cmd = "%s build --environment %s --output-path %s" % \ (ember_bin, env, "../synnefo_ui/static/snf-ui/") ret = sp.call(cmd, shell=True) if ret == 1: raise Exception("ember build failed") os.chdir(setupdir)
def build_ember_project(): import subprocess as sp from distutils.spawn import find_executable as find project_dir = os.path.join(".", "snf-ui") if not os.path.exists(project_dir): os.mkdir(project_dir) setupdir = os.getcwd() os.chdir(project_dir) env = os.environ.get('SNFUI_AUTO_BUILD_ENV', 'production') cache_args = ["--cache-min", "99999999"] if not find("npm"): raise Exception("NPM not found please install nodejs and npm") if not os.path.exists("./node_modules"): print "Install npm dependencies" ret = sp.call(["npm", "install", "--silent"] + cache_args) if ret == 1: raise Exception("ember install failed") ember_bin = "./node_modules/ember-cli/bin/ember" if not os.path.exists(ember_bin): print "Installing ember-cli..." sp.call(["npm", "install", "ember-cli"]) bower_bin = "bower" if find("bower") is None: bower_bin = "./node_modules/bower/bin/bower" if not os.path.exists(bower_bin): print "Installing bower..." sp.call(["npm", "install", "bower"] + cache_args) if not os.path.exists("./bower_components"): print "Install bower dependencies" ret = sp.call([bower_bin, "install", "--allow-root", "--quiet"]) if ret == 1: raise Exception("bower install failed") ret = sp.call([ ember_bin, "build", "--environment", env, "--output-path", "../synnefo_ui/static/snf-ui" ]) if ret == 1: raise Exception("ember build failed") os.chdir(setupdir)
def build_ember_project(): import subprocess as sp from distutils.spawn import find_executable as find project_dir = os.path.join(".", "snf-ui") if not os.path.exists(project_dir): os.mkdir(project_dir) setupdir = os.getcwd() os.chdir(project_dir) env = os.environ.get('SNFUI_AUTO_BUILD_ENV', 'production') cache_args = ["--cache-min", "99999999"] if not find("npm"): raise Exception("NPM not found please install nodejs and npm") if not os.path.exists("./node_modules"): print "Install npm dependencies" ret = sp.call(["npm", "install", "--silent"] + cache_args) if ret == 1: raise Exception("ember install failed") ember_bin = "./node_modules/ember-cli/bin/ember" if not os.path.exists(ember_bin): print "Installing ember-cli..." sp.call(["npm", "install", "ember-cli"]) bower_bin = "bower" if find("bower") is None: bower_bin = "./node_modules/bower/bin/bower" if not os.path.exists(bower_bin): print "Installing bower..." sp.call(["npm", "install", "bower"] + cache_args) if not os.path.exists("./bower_components"): print "Install bower dependencies" ret = sp.call([bower_bin, "install", "--allow-root", "--quiet"]) if ret == 1: raise Exception("bower install failed") ret = sp.call([ember_bin, "build", "--environment", env, "--output-path", "../synnefo_ui/static/snf-ui"]) if ret == 1: raise Exception("ember build failed") os.chdir(setupdir)
def __init__(self): super(AvatarConfig, self).__init__() self.config_file = realpath(expanduser(CONFIG_FILE)) self.config_path = dirname(self.config_file) mkpath(expanduser(self.config_path)) # create config dir if neccessary # Create a default config if there's no config file yet if self.read(expanduser(CONFIG_FILE)) == []: self.add_section('DIST') self.add_section('TARGETS') has_apt = 'True' if find('apt-get') else 'False' self.set('DIST', 'has_apt', has_apt) self.set('DIST', 'default_install_path', self.config_path + '/') for t_name, t_dict in TARGETS.items(): path = t_dict.get('sys_name', t_dict.get('apt_name', 'None')) full_path = find(path) or 'None' self.set('TARGETS', t_name, full_path)
def git_install(self, local_directory, repository, install_commands, branch='master', apt_deps=None, configure_options=None, make_options=None, install_script=None): get_terminal_screen() if apt_deps != '': system('echo') system('echo [*] Installing dependencies...') res = system('sudo apt-get install %s' % apt_deps) sleep(1.5) if res != 0: raise Exception('Fail to install dependencies %s' % apt_deps) system('echo') system('echo [*] Installing from git...') git_exec = find('git') system('%s clone %s --single-branch --branch %s %s' % (git_exec, repository, branch, local_directory) ) chdir(local_directory) if install_script is None or install_script.strip() == '': for cmd in install_commands: if cmd == './configure' and configure_options is not None: res = system(cmd + ' ' + configure_options) elif cmd == 'make' and make_options is not None: res = system(cmd + ' ' + make_options) else: res = system(cmd) if res != 0: sleep(2) raise Exception('Executing install command \'%s\' failed' % cmd) else: res = system('echo ' + install_script + ' ' + configure_options) res = system(install_script + ' ' + configure_options) if res != 0: raise Exception('Install script %s failed' % install_script) exec_path = '%s/%s' % (self.install_dir, TARGETS[self.current_target]['rel_path']) if exists(exec_path): self.config.set('TARGETS', self.current_target, exec_path)
from pathlib import Path from subprocess import Popen from tempfile import mkdtemp from textwrap import dedent from threading import Thread from unittest import TestCase, TestSuite from urllib.parse import urlparse from test.test_data import test_data logging.basicConfig(format="%(message)s") logger = logging.getLogger(__name__) test_data_by_path = {urlparse(url).path: text for url, text in test_data.items()} mypdns_hosts2rpz = find("hosts2rpz.py") or find("hosts2rpz") cache_dir = os.getenv("CACHE_DIR", "/var/cache/mypdns-hosts2rpz") named_user = os.getenv("NAMED_USER", "named") test_origin = "rpz.example.com." class LoggingRequestHandler(SimpleHTTPRequestHandler): def log_message(self, format, *args): logger.info( "%s - - [%s] %s" % (self.address_string(), self.log_date_time_string(), format % args) )
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Setup file for bootstrap. This file was generated with PyScaffold 2.5.8, a tool that easily puts up a scaffold for your new Python project. Learn more under: http://pyscaffold.readthedocs.org/ """ import sys from setuptools import setup from distutils.spawn import find_executable as find find("git") or sys.exit("Please install git") if sys.version_info < (3, 5): sys.exit("ERROR: Python 3.5 required.") def setup_package(): needs_sphinx = {"build_sphinx", "upload_docs"}.intersection(sys.argv) sphinx = ["sphinx"] if needs_sphinx else [] setup(setup_requires=["six", "pyscaffold>=2.5a0,<2.6a0"] + sphinx, use_pyscaffold=True) if __name__ == "__main__": setup_package()