Ejemplo n.º 1
0
def start_all():
    print(banner.info('Starting all applications'))

    processes = []
    for project_id in conf['projects']:
        project = conf['projects'][project_id]
        path = conf['parameters']['projects_dir'] + '/' + project_id

        if not os.path.exists(path):
            print(banner.info('Ignoring ' + project['name'] + ' (not installed)'))
            continue

        properties = yaml.load(open(path + '/.p-properties.yml', 'r'))

        if 'run' not in properties:
            print(banner.info('Ignoring ' + project['name'] + ' (no running configuration)'))
            continue

        for command in properties['run']:
            print(banner.info('Starting ' + project['name']))

            processes.append(Popen(command, shell=True, cwd=path))
            sleep(2)

    print(banner.success('All projects started!'))
    print('Press Ctrl-C to quit.')

    for process in processes:
        try:
            process.wait()
        except KeyboardInterrupt:
            sys.exit(0)
Ejemplo n.º 2
0
def install(name, description, url, path):
    print(banner.info('Now installing ' + name))
    print(description)

    print(banner.info('Using ' + cloning_method + ' cloning method'))
    print(
        'You may change the cloning method by passing https or ssh as an argument.'
    )

    call(['git', 'clone', url, path])
Ejemplo n.º 3
0
def check_requirements(project_id):
    res = 0
    conf = yaml.load(open('config.yml', 'r'))
    path = conf['parameters']['projects_dir'] + '/' + project_id
    properties = yaml.load(open(path + '/.p-properties.yml', 'r'))

    print(
        banner.info('Checking requirements for ' +
                    conf['projects'][project_id]['name']))

    dependencies = properties['dependencies']
    for bin_dependency in dependencies.get('bin', []):
        print('Checking if ' + bin_dependency + ' is installed...', end='')
        res = check_result(
            call(['which', bin_dependency], stdout=open(os.devnull,
                                                        'w'))) or res

    for script_dependency in dependencies.get('script', []):
        print('Running script ' + script_dependency + '...', end='')
        res = check_result(
            call(script_dependency, shell=True, stdout=open(os.devnull,
                                                            'w'))) or res

    if res:
        print(banner.error('Some requirements are missing!'))
        print(
            'Check the script trace and run the update script to finish installation.'
        )
        exit(res)
    else:
        print(banner.success('Your system meets requirements'))
Ejemplo n.º 4
0
def update(name, path):
    print(banner.info('Now updating ' + name))

    update_confirmation()

    call(['git', 'stash', 'save'], cwd=path)
    call(['git', 'checkout', 'master'], cwd=path)
    call(['git', 'pull'], cwd=path)
Ejemplo n.º 5
0
def confirm_removal():
    print(banner.info('BEWARE! All projects will be deleted!'))

    print('History will be lost, and all code in ' + projects_dir + ' folder will be deleted. '
          'There is no coming back. Continue? [y/N] ')

    choice = input().lower()
    if choice != 'y':
        exit(1)
Ejemplo n.º 6
0
def update_confirmation():
    print(banner.info('Are you sure you want to continue?'))
    print(
        'I will stash potential uncommitted changes, checkout master and pull the last commit from origin. '
        'Continue? [y/N] ')

    choice = input().lower()
    if choice != 'y':
        exit(1)
Ejemplo n.º 7
0
def self_update():
    print(banner.info('Self-updating...'))

    call(['git', 'checkout', 'master'])
    call(['git', 'pull'])