Пример #1
0
 def sync(self):
     if not os.path.exists(self.path):
         logger.info('downloading %s' % Color.GREEN+self.name+Color.END)
         op_ok = self.download()
     else:
         logger.info('updating %s' % Color.GREEN+self.name+Color.END)
         op_ok = self.update()
     if op_ok:
         unnest_dir(self.path)
Пример #2
0
 def build(self):
     if self.build_commands is None:
         return True
     logger.info('building %s' % Color.GREEN+self.name+Color.END)
     op_ok = False
     with chdir(self.path):
         for cmd in self.build_commands:
             op_ok = run_command(cmd)
             if not op_ok:
                 break
     return op_ok
Пример #3
0
 def do_genspec(self, args):
     """
     Scans current folder for versionned applications and
     creates a specfile accordingly.
     """
     self.setup_config_dir(args.path)
     new_specs = {
         'path': args.path,
         'apps': {}
     }
     if args.merge is not None:
         new_specs = self.load_specs(args.merge)
     apps_specs = new_specs['apps']
     new_apps_found = False
     for vcs_type, app_folder in find_versionned_folders(args.path):
         app_path = app_folder[len(args.path)+1:]
         if app_path not in [apps_specs[a]['path'] for a in apps_specs]:
             new_apps_found = True
             folder, app_name = os.path.split(app_folder)
             logger.info('found%s application in %s: %s (%s)' % (
                 ' new' if args.merge is not None else '',
                 folder, Color.GREEN+app_name+Color.END, vcs_type
             ))
             cfg_file, regex, handler = self.vcs_repo_finders[vcs_type]
             cfg_path = os.path.join(app_folder, cfg_file)
             app_specs = {
                 'type': vcs_type,
                 'url': handler(regex, cfg_path),
                 'path': app_path,
             }
             apps_specs[app_name] = app_specs
     if new_apps_found:
         outfile = args.merge or args.file
         if os.path.exists(outfile):
             logger.warning('file already exists: %s' % Color.GREEN+outfile+Color.END)
             if not yes_no('Overwrite ?'):
                 logger.error('operation aborted by user')
                 return
         with open(outfile, 'w') as ofile:
             json.dump(new_specs, ofile, sort_keys=True, indent=2, separators=(',', ': '))
         logger.info('specfile written to %s' % Color.GREEN+outfile+Color.END)
         logger.info('you may now add build information to the new specfile')
     else:
         logger.info('no new application found')