def run(params): scripts_key = params.cmd package_file_data = read_conf() if package_file_data.has_key('scripts'): scripts = package_file_data['scripts'] if scripts_key in scripts.keys(): utils.cmd_with_check_os_value(scripts[scripts_key]) else: print 'missing script: {0}'.format(scripts_key) else: print 'there\'s no scripts'
def uninstall(params): package_file_data = read_conf() if params.packages == '*': packages = packages_manage(package_file_data, Manage.GET) package_file_data = packages_manage(package_file_data, Manage.REMOVEALL) if not utils.cmd_with_check_os_value('pip uninstall {0}'.format( ' '.join(packages))): write_conf(package_file, package_file_data) else: package_file_data = packages_manage(package_file_data, Manage.REMOVE, params.packages) if not utils.cmd_with_check_os_value('pip uninstall {0}'.format( ' '.join(params.packages))): write_conf(package_file, package_file_data)
def init(params): ''' Project initialation package.yml base conf - name - version - author ''' if not utils.check_file_exists( os.path.join(params.name, package_file) if params. name else package_file): package_file_data = {} package_file_data[ 'name'] = params.name if params.name else project_name package_file_data['author'] = getpass.getuser() package_file_data[ 'version'] = '1.0.0' # version formating: [project version].[feature version].[bug version] write_conf( os.path.join(params.name, package_file) if params.name else package_file, package_file_data) if params.env: virtualenv = { 'cmd': 'virtualenv', 'args': [ os.path.join( os.getcwd(), os.path.dirname( os.path.join(params.name, package_file) if params. name else package_file), 'venv') ] } if params.sys: virtualenv['args'].append('--system-site-packages') if params.nosys: virtualenv['args'].append('--no-site-packages') args = virtualenv['args'] args.insert(0, virtualenv['cmd']) cmd_string = ' '.join(args) if not utils.cmd_with_check_os_value(cmd_string): cmd = 'source {0}'.format( os.path.join( os.path.dirname( os.path.join(params.name, package_file) if params. name else package_file), 'venv', 'bin', 'activate')) print 'Enter command \'{0}\' to start your project.'.format( cmd) else: print 'package.yml already exists' exit(0)
def install(params): ''' Install python package with pip ''' package_file_data = read_conf() if params['packages'] == '*' if type( params) == dict else params.packages == '*': packages = packages_manage(package_file_data, Manage.GET) if len(packages) > 0: utils.cmd_with_check_os_value('pip install {0}'.format( ' '.join(packages))) else: package_file_data = packages_manage(package_file_data, Manage.ADD, params.packages, params.dev) if not utils.cmd_with_check_os_value('pip install {0}'.format(' '.join( params.packages))): write_conf(package_file, package_file_data)
def update(params): package_file_data = read_conf() if params['packages'] == '*' if type( params) == dict else params.packages == '*': package_file_data = packages_manage(package_file_data, Manage.UPDATE, None, params.dev) else: package_file_data = packages_manage(package_file_data, Manage.UPDATE, params.packages, params.dev) packages = packages_manage(package_file_data, Manage.GET) if len(packages) > 0: if not utils.cmd_with_check_os_value('pip install -U {0}'.format( ' '.join(packages))): write_conf(package_file, package_file_data)