Esempio n. 1
0
 def error_check(self):
     # Check syntax
     if self.linkeddir == '' or self.localdir=='':
         raise SyntaxError(messages.syn_error_noname)
     if not re.search('\*',self.linkedfile) and re.search('\*',self.localfile):
         raise SyntaxError(messages.syn_error_wildfilename1.replace('\n',''))
     if re.search('\*',self.localfile) and not re.search('\*$',self.localfile):
         raise SyntaxError(messages.syn_error_wildlocalfile.replace('\n',''))
    def error_check_local(self):
        # Check syntax
        if self.file == '' or self.outfile == '' or self.outdir == '':
            raise SyntaxError(messages.syn_error_noname)
        if not re.search('\*', self.file) and re.search('\*', self.outfile):
            raise SyntaxError(
                messages.syn_error_wildfilename1.replace('\n', ''))
        if re.search('\*',
                     self.outfile) and not re.search('\*$', self.outfile):
            raise SyntaxError(messages.syn_error_wildoutfile.replace('\n', ''))
        if len(re.findall('\*', self.outfile)) > 1:
            raise SyntaxError(messages.syn_error_wildoutfile.replace('\n', ''))

        # Check wildcard directory non-empty
        if self.flag_list and not self.LIST:
            raise LogicError(messages.crit_error_emptylist)
Esempio n. 3
0
    def __init__(self, kwargs, program_bool=False):
        RunProgramDirective.__init__(self, kwargs, program_bool)

        if 'command' in kwargs.keys():
            self.command = kwargs['command']
            self.command = re.sub('\\\\', '/', self.command)
        else:
            raise SyntaxError(messages.syn_error_nocommand)
    def error_check(self):
        if not re.match('\d+$', self.rev) and self.rev != '':
            raise SyntaxError(messages.syn_error_revnum %
                              (self.rev, self.dir, self.file))
        if self.dir == '' and self.rev != '' or self.dir != '' and self.rev == '':
            raise LogicError(
                messages.logic_error_revdir.replace('\n', '') %
                (self.dir, self.file, self.rev, self.dir))

        SystemDirective.error_check(self)
Esempio n. 5
0
    def __init__(self, kwargs, program_bool=False):
        RunProgramDirective.__init__(self, kwargs, program_bool)

        if 'package' in kwargs.keys():
            self.package = kwargs['package']
            self.package = re.sub('\\\\', '/', self.package)
        else:
            raise SyntaxError(messages.syn_error_nopackage)

        if 'lib' in kwargs.keys():
            self.lib = '-l ' + kwargs['lib']
        else:
            self.lib = ''
    def get_asset_data(self):
        import requests
        split_url = urlparse.urlsplit(self.url)
        path = split_url.path
        path = path.split("/")
        clean_path = []
        assetid = None

        for i in range(len(path)):
            if bool(path[i]):
                clean_path.append(path[i])
        if len(clean_path) != 6:
            raise SyntaxError(messages.syn_error_url)

        organization, repo, releases, download, tag, assetname = clean_path
        prelim_path = "https://" + self.token + ":@api.github.com/repos/"
        paste_prelim = "https://" + "[token]" + ":@api.github.com/repos/"
        releasepath         = prelim_path  + organization + "/" + repo + "/" + \
                              releases + "/" + "tags" + "/" + tag
        releasepath_paste   = paste_prelim + organization + "/" + repo + "/" + \
                              releases + "/" + "tags" + "/" + tag

        # Accessing GitHub API for asset ID
        try:
            s = requests.session()
            json_release = s.get(releasepath)
            json_output = json_release.content
            json_split = json_output.split(",")
            json_name = '"name":"' + assetname + '"'
        except:
            raise CritError(messages.crit_error_github % releasepath_paste)

        # Finding asset ID in JSON output
        for i in range(len(json_split)):
            if json_split[i] == json_name:
                assetid = json_split[i - 1]
                assetid = assetid.split(":")
                assetid = assetid[1]

        # Creating download url
        if assetid is None:
            raise CritError(messages.crit_error_assetid % (assetname, tag))
        else:
            assetpath       = prelim_path  + organization + "/" + repo + "/" + \
                              releases + "/" + "assets" + "/" + assetid
            paste_assetpath = paste_prelim + organization + "/" + repo + "/" + \
                              releases + "/" + "assets" + "/" + assetid

        self.url = assetpath
        self.paste_url = paste_assetpath
        self.file = assetname
Esempio n. 7
0
    def __init__(self, kwargs, program_bool=True):
        dict((k.lower(), v) for k, v in kwargs.iteritems())

        if program_bool:
            if 'program' in kwargs.keys():
                program_input = kwargs['program']
                self.program_path = os.path.dirname(program_input)
                program_base = os.path.basename(program_input)
                self.program_name, self.program_ext = os.path.splitext(
                    program_base)
            else:
                raise SyntaxError(messages.syn_error_noprogram)

            if self.program_path == '':
                self.program_path = './'
        else:
            self.program_ext = ''

        if 'makelog' in kwargs.keys():
            self.makelog = kwargs['makelog']
            if self.makelog:
                self.makelog = os.path.abspath(self.makelog)
        else:
            self.makelog = os.path.abspath(metadata.settings['makelog_file'])

        if 'option' in kwargs.keys():
            self.option = kwargs['option']
            self.option_dict = self.parse_options()
            self.option_overlap_error_check(kwargs)
        else:
            self.option = ''
            self.option_dict = {}

        if 'log' in kwargs.keys():
            self.log = os.path.abspath(kwargs['log'])
        else:
            self.log = self.option_assigned('log', '')

        if 'lst' in kwargs.keys():
            self.lst = os.path.abspath(kwargs['lst'])
        else:
            self.lst = self.option_assigned('lst',
                                            metadata.settings['output_dir'])

        if 'changedir' in kwargs.keys():
            self.changedir = kwargs['changedir']
        else:
            self.changedir = False

        if 'executable' in kwargs.keys():
            self.executable = kwargs['executable']
        else:
            self.executable = ''

        if 'args' in kwargs.keys():
            self.args = kwargs['args']
        else:
            self.args = ''

        if 'handout' in kwargs.keys():
            self.handout = kwargs['handout']
        else:
            self.handout = False

        if 'comments' in kwargs.keys():
            self.comments = kwargs['comments']
        else:
            self.comments = False

        if 'pdfout' in kwargs.keys():
            self.pdfout = os.path.abspath(kwargs['pdfout'])
        else:
            pdfout_dir = ''
            if self.handout or self.comments:
                pdfout_dir = metadata.settings['temp_dir']
            else:
                pdfout_dir = metadata.settings['output_dir']
            self.pdfout = self.option_assigned('pdfout', pdfout_dir)

        self.osname = os.name
        self.option = self.update_option()