def setup_config_dir(self, path):
     self.config_dir = os.path.join(
         self.config_basedir,
         path.replace(os.path.sep, '_').strip('_')
     )
     if not os.path.exists(self.config_dir):
         logger.debug('creating configuration folder: %s' % Color.GREEN+self.config_dir+Color.END)
         os.makedirs(self.config_dir)
Exemple #2
0
 def store_version(self):
     version_file = os.path.join(self.tba.config_dir, self.name)
     logger.debug('writing version for %s to %s' % (
         Color.GREEN+self.name+Color.END,
         Color.GREEN+version_file+Color.END
     ))
     with open(version_file, 'w') as ofile:
         ofile.write(self.url.split('/')[-1].split('?')[0])
def get_svn_url(regex, path):
    cmd = 'LANG=en svn info'
    logger.debug('running external command: %s' % Color.GREEN+cmd+Color.END)
    with chdir(path):
        p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
    svn_info, _ = p.communicate()
    for line in svn_info.splitlines():
        logger.debug(Color.BLUE+line+Color.END)
    url = regex.search(svn_info).group(1)
    return url
Exemple #4
0
 def read_version(self):
     version_file = os.path.join(self.tba.config_dir, self.name)
     logger.debug('reading version for %s from %s' % (
         Color.GREEN+self.name+Color.END,
         Color.GREEN+version_file+Color.END
     ))
     if not os.path.exists(version_file):
         return None
     with open(version_file) as ifile:
         version = ifile.read().strip()
     logger.debug('version for %s is %s' % (
         Color.GREEN+self.name+Color.END,
         Color.GREEN+version+Color.END
     ))
     return version
def run_command(cmd):
    logger.debug('running external command: %s' % Color.GREEN + cmd + Color.END)
    cmd = shlex.split(cmd)
    p = Popen(cmd, shell=False, stdout=PIPE, stderr=PIPE)
    stdout, stderr = p.communicate()
    # display STDOUT content
    if stdout:
        for line in stdout.splitlines():
            logger.debug(Color.BLUE+line+Color.END)
    # display an error (STDERR or generic message) if returncode is non-zero
    if p.returncode != 0:
        tmpname = log_to_file(stderr)
        logger.error('an error occured, see %s for more details' % (Color.GREEN+tmpname+Color.END))
        return False
    return True
 def load_specs(self, fpath):
     """
     Loads a specifications file and checks for missing fields.
     """
     with open(fpath) as ifile:
         logger.debug('loading specfile: %s' % Color.GREEN+fpath+Color.END)
         data = json.load(ifile)
     for field in self.tba_required_fields:
         if field not in data:
             logger.error('missing top-level field in specs: %s' % Color.GREEN+field+Color.END)
             return None
     for app_name in data['apps']:
         app_specs = data['apps'][app_name]
         for app_field in self.app_required_fields:
             if app_field not in app_specs:
                 logger.error('missing app field in specs: %s' % Color.GREEN+app_field+Color.END)
                 return None
     return data