Esempio n. 1
0
 def downepi(self, episode):
     """ down a show """
     pos = self.visible.posend
     url, dest, cook = links.flvdown(episode, "")
     if url:
         try:
             if (not ospath.isdir(dest.split('/')[0])):
                 osmkdir(dest.split('/')[0])
             cmd = "wget -c " + url + " -O " + dest
             proc = subpopen(cmd, shell=True, stderr=PIPE, stdout=PIPE)
             while proc.poll() is None:
                 line = proc.stderr.readline()
                 resul = down.search(line[:-1])
                 if resul:
                     msg = resul.group(1) + ' ' + resul.group(2) + \
                             ' ' + resul.group(3)
                 self.screen.addstr(pos[0], pos[1]+pos[2], msg)
                 self.screen.refresh()
             subdown.downSub(episode, "")
         except:
             proc.kill()
             self.error(episode.getBaseName() + ': down error')
         else:
             self.error(episode.getBaseName() + ': down finish')
             episode.isOnDisk = True
             self.display()
     else:
         self.error(episode.getBaseName() + ': url not found')
Esempio n. 2
0
def CREATE_DIR(OUTDIR):
    if not pathexists(pathjoin(OUTDIR)):
        osmkdir(pathjoin(OUTDIR))

    for DIR in ["IdListDIR", "IdListDIR/disease", "IdListDIR/query"]:
        if not pathexists(pathjoin(OUTDIR, DIR)):
            osmkdir(pathjoin(OUTDIR, DIR))
Esempio n. 3
0
 def saveConf(self):
     """ save the config"""
     if (not ospath.exists(ospath.expanduser('~') + "/.config/flvdown/")):
         osmkdir(ospath.expanduser('~') + "/.config/flvdown/")
     fileconf = open(ospath.expanduser('~') + \
         "/.config/flvdown/flv.conf", "w", 0)
     for key in self.conf.keys():
         fileconf.write(key + '="' + self.conf[key] + '\"\n')
     fileconf.write('order="')
     for elt in self.list_site:
         fileconf.write(elt + ', ')
     fileconf.write('"\n')
     fileconf.write('dict_bug=')
     fileconf.write(repr(self.dict_bug))
     fileconf.write('\n')
     
     fileconf.close()
Esempio n. 4
0
 def createDir(self):
     """ create directory if it doesn't exist """
     if (not ospath.isdir(self.tvshow_)):
         osmkdir(self.tvshow_)
Esempio n. 5
0
        f.write('export CSCOPE_DB="%s"\n'         % OutCscopeDb )
        f.write('export tagsfile="%s"\n'          % OutCtagsTags)
        f.write('export TAGS_HL="%s"\n'           % OutVimTagsHl)
        f.write('export VIMPROJSERVERNAME="%s"\n' % WorkDir     )
 
if __name__ == "__main__":
    from os import path as osp
    from os import environ as ose
    from os import makedirs as osmkdir
    
    WorkDir = osp.abspath(osp.curdir)
    VimTagsPathRoot = osp.join(ose['HOME'], '.vimtagsroot')
    WorkDirFlat = "".join([ c if c.isalnum() else "_" for c in WorkDir ])
    VimTagsPath = osp.join(VimTagsPathRoot, WorkDirFlat)
    if not osp.isdir(VimTagsPath):
        osmkdir(VimTagsPath)
    
    OutFilesList = osp.join(VimTagsPath, 'files.list')
    OutCscopeDb  = osp.join(VimTagsPath, 'cscope.out')
    OutCtagsTags = osp.join(VimTagsPath, 'tags')
    OutVimTagsHl = osp.join(VimTagsPath, 'tags_hl.vim')
    OutExportVar = osp.join(VimTagsPath, 'export_var_for_vim')
    
    TagsIgnoreFile = osp.join(WorkDir, '.7tags.ignore')
    TagsAddFile    = osp.join(WorkDir, '.7tags.add')

    ExtensionList = [ 'h', 'c', 'cc', 'cpp', 'hpp' ]

    log("Tags artifact will be stored in %s" % VimTagsPath)

    log(" + Generate files list")
Esempio n. 6
0
def efetch_found_bioprojects(OUTDIR):


    def printProgressBar (iteration, total, prefix = '', suffix = '', \
                      decimals = 1, length = 100, fill = '█'):
        """
        Call in a loop to create terminal progress bar
        @params:
            iteration   - Required  : current iteration (Int)
            total       - Required  : total iterations (Int)
            prefix      - Optional  : prefix string (Str)
            suffix      - Optional  : suffix string (Str)
            decimals    - Optional  : positive number of decimals in percent \
                                      complete (Int)
                                      length      - Optional  : character length of bar (Int)
                                      fill        - Optional  : bar fill character (Str)
        """
        percent = ("{0:." + str(decimals) + "f}")\
                                    .format(100 * (iteration / float(total)))
        filledLength = int(length * iteration // total)
        bar = fill * filledLength + '-' * (length - filledLength)
        print('\r%s |%s| %s%% %s' % (prefix, bar, percent, suffix), end='\r')
        # Print New Line on Complete
        if iteration == total:
            print()

    """
    COLETAR INFORMAÇOES SOBRE BIOPROJECTS ECONTRADOS
    """

    if pathexists(OUTDIR):

        for DIR in ['Bioprojects', 'Bioprojects/xml']:
            if not pathexists(pathjoin(OUTDIR, DIR)):
                osmkdir(pathjoin(OUTDIR, DIR))

        path_to_list = pathjoin(OUTDIR, 'IdListDIR/IdList_total.txt')
        if isfile(path_to_list):
            with open(path_to_list, 'r') as f:
                IdList_total = list(filter(None, f.read().splitlines()))
        else:
            print('File '+f+' was not found. Run esearch_disease(OUTDIR) '\
                  'for making it.')
            exit()
    else:
        print('Directory '+pathjoin(OUTDIR)+' is not accessible. Did you run'\
              'esearch_disease() previously? If not, do it and try again.')
        exit()

    df2 = pd_DataFrame(index=range(0, len(IdList_total)), columns=range(0, 7))
    df2.columns = [
        "ID", "accession", "GEO", "title", "abstract", "disease", "COD"
    ]
    df2["ID"] = IdList_total

    print("\n\n")  # ESSE PRINT SERVE PARA DISTANCIAR A BARRA DE PROCESSAMENTO
    # QUE VEM LOGO ABAIXO DENTRO DO LOOPING

    # prepare bar progress
    l = len(IdList_total)
    i = 0
    printProgressBar(0, l, prefix='Download:', suffix='Complete', length=50)

    RECALL = []  # if download fails, the ID is stored in RECALL
    DIC_ID = {}
    for ID in IdList_total:

        try:
            handle = Entrez.efetch(db="bioproject", id=ID)
        except:
            RECALL += [ID]
            print('handle = Entrez.efetch(db="bioproject", id=' + ID +
                  ')\tFAILED')
            continue  # avoid catastrophic event in case NCBI fails to give
            # the informatio for one ID
        try:
            record = handle.read()
            root = ET.fromstring(record)
            DIC = root.find(".//ProjectID/ArchiveID").attrib
            DIC_ID[DIC['accession']] = DIC_ID.get(DIC['accession'], DIC['id'])

            outfile=pathjoin(OUTDIR,'Bioprojects/xml',DIC['accession']+\
                                 '_'+DIC['id']+'.xml')

            #print(outfile)
            with open(outfile, "w", encoding="utf-8") as f:
                print(record, file=f)

        except:
            RECALL += [ID]
            print('FAILED to process ' + ID + ' during the first trial')
            continue

        printProgressBar(i + 1,
                         l,
                         prefix='Download:',
                         suffix='Complete',
                         length=50)
        i += 1

    # RECALL for failure IDs
    if len(RECALL) > 0:
        print("\n\nFailure to download IDs. STARTING RECALL.")

        l = len(RECALL)
        i = 0
        printProgressBar(0,
                         l,
                         prefix='Download:',
                         suffix='Complete',
                         length=50)
        RECALL2 = []
        for ID in RECALL:

            try:
                handle = Entrez.efetch(db="bioproject", id=ID)
            except:
                RECALL2 += [ID]
                print('handle = Entrez.efetch(db="bioproject", id='+ID+')'\
                      '\tFAILED in RECALL')
                continue
            try:
                record = handle.read()
                root = ET.fromstring(record)
                DIC = root.find(".//ProjectID/ArchiveID").attrib
                DIC_ID[DIC['accession']] = DIC_ID.get(DIC['accession'],
                                                      DIC['id'])

                outfile=pathjoin(OUTDIR,'Bioprojects/xml',DIC['accession']+\
                                     '_'+DIC['id']+'.xml')

                #print(outfile)
                with open(outfile, "w", encoding="utf-8") as f:
                    print(record, file=f)
            except:
                RECALL2 += [ID]
                print('FAILED to process ' + ID + ' during the RECALL')
                continue

            printProgressBar(i + 1,
                             l,
                             prefix='RECALL:',
                             suffix='Complete',
                             length=50)
            i += 1

        if len(RECALL2) > 0:
            outfile = pathjoin(OUTDIR, 'Bioprojects/', 'RECALL_failure.txt')
            open(outfile, 'w').write(str(RECALL2))
            print("It was not possible to get ID even during the RECALL\nYou"\
                  "can find the problematic IDs on file:\n"+outfile)

    outfile = pathjoin(OUTDIR, 'Bioprojects/', 'dict_ID_ACC.txt')
    open(outfile, 'w').write(str(DIC_ID))