コード例 #1
0
def processFile(UPLOAD_FOLDER, OUTPUT_FOLDER, MAX_PROCESSES, Settings,
                filenameList):
    if not os.path.exists("tmp/"):
        os.makekdirs("tmp/")
    #select correct processing method
    xml = set(['xml'])
    img = set(['pdf', 'png', 'jpg', 'jpeg', 'tif'])
    text = set(['doc', 'docx', 'odt', 'txt'])
    i = 0
    if MAX_PROCESSES == 0:
        MAX_PROCESSES = len(filenameList)
    pool = Pool(processes=MAX_PROCESSES)

    while i < len(filenameList):
        filename = filenameList[i]
        if check_file_extension(filename, xml):
            Settings[0] = "XML"
            pool.apply_async(fileuploadXML, (
                UPLOAD_FOLDER,
                OUTPUT_FOLDER,
                filename,
            ))
        if check_file_extension(filename, img):
            if check_file_extension(filename, set(
                ['pdf'])) and "TXT" in Settings[0]:
                Settings[0] = "TXT"
                pool.apply_async(fileuploadText, (
                    UPLOAD_FOLDER,
                    OUTPUT_FOLDER,
                    Settings,
                    filename,
                ))
            else:
                Settings[0] = "IMG"
                pool.apply_async(fileuploadIMG, (
                    UPLOAD_FOLDER,
                    OUTPUT_FOLDER,
                    Settings,
                    filename,
                ))
        if check_file_extension(filename, text):
            Settings[0] = "TXT"
            pool.apply_async(fileuploadText, (
                UPLOAD_FOLDER,
                OUTPUT_FOLDER,
                Settings,
                filename,
            ))

        i += 1

    #sync process
    pool.close()
    pool.join()
コード例 #2
0
ファイル: mweb.py プロジェクト: tuling56/Python
        # 图像设置
        plt.figure(figsize=(15,7))  # figsize()设置的宽高比例是是15:7,图片的尺寸会根据这个比例进行调节
        lowlimit=min(view)-500      #y轴下限
        highlimit=max(view)+500     #y轴上限
        plt.ylim(lowlimit,highlimit)
        plt.grid(which='both')

        # 绘制原始数据
        plt.plot(range(1,len(view)+1),view,color='y',lw=0.5,label='origin')
        plt.legend(loc='upper right')
        plt.xlabel('time (s)')
        plt.ylabel('views')

        # 当存在高潮区间的时候标注高潮区间
        if high:
            for item in high:
                plt.annotate('',xy=(item[1],1000),xytext=(item[0],1000),arrowprops=dict(arrowstyle="->",connectionstyle="arc3"))
                plt.fill_betweenx([lowlimit,highlimit],item[0], item[1], linewidth=1, alpha=0.2, color='r')

        # 结果保存(能不能不保存,直接获取图像数据显示)
        despath='D:\\hot_pic1'
        if not os.path.exists(despath):
            os.makekdirs(despath)
        fname=os.path.join(despath,cid+'.'+str(filesize)+'.jpg')
        plt.savefig(fname,dpi = 300)
        plt.close()

if __name__ == "__main__":
    app.run()
    #dbx=DBO()
    #dbx.GET()
コード例 #3
0
ファイル: getjs.py プロジェクト: rwilkins87/cogent-house
def downloadDojo(thePath):
    """Download the Dojo JS toolkit"""
    DOJO_URL = "http://download.dojotoolkit.org/release-{0}/dojo-release-{0}.tar.gz".format(DOJO_VERSION)

    dojoFile =os.path.join(thePath,
                           "dojo-release-{0}.tar.gz".format(DOJO_VERSION))

    dojopath = os.path.join(thePath, "dojo")

    if os.path.exists(dojoFile):
        print "Dojo Exists"        
    else:
        print "Downloading Dojo"
        urllib.urlretrieve(DOJO_URL,dojoFile)
        dojoTar = tarfile.open(dojoFile)
        dojoTar.extractall(thePath)

        #Overwrite any existing version
        if os.path.isdir(dojopath):
            print("Directory Exists")
            shutil.rmtree(dojopath)

        dojosource =os.path.join(thePath,
                                 "dojo-release-{0}".format(DOJO_VERSION))
        print "Source {0} Dest {1}".format(dojosource,
                                           dojopath)
                            
        shutil.copytree(dojosource,
                        dojopath)

    myWidget = os.path.join(dojopath,"MyWidgets")
    myexists = os.path.exists(myWidget)
    if not myexists:
        fullPath = os.path.join(myWidget,"form")
        os.makekdirs(fullPath)
        shutil.copy("cogentviewer/static/DateTimeBox.js",fullPath)
        
    #Then check for the dgrid etc modules
    dgridpath = os.path.join(dojopath,"dgrid")
    dexists = os.path.exists(dgridpath)
    print "Check for {0} {1}".format(dgridpath,dexists)
    
    if not dexists:
        print "No Dgrid"
        subprocess.call(["git",
                         "clone",
                         "https://github.com/SitePen/dgrid.git",
                         dgridpath])


    #And dgrid dependencies
    thepath = os.path.join(dojopath,"xstyle")
    exists = os.path.exists(thepath)
    print "Check for {0} {1}".format(thepath,exists)
    if not exists:
        print "No X Style"
        subprocess.call(["git",
                         "clone",
                         "https://github.com/kriszyp/xstyle.git",
                         thepath])

    thepath = os.path.join(dojopath,"put-selector")
    exists = os.path.exists(thepath)
    print "Check for {0} {1}".format(thepath,exists)
    if not exists:
        print "No Put Selector"
        subprocess.call(["git",
                         "clone",
                         "https://github.com/kriszyp/put-selector.git",
                         thepath])    
コード例 #4
0
ファイル: getjs.py プロジェクト: honir/cogent-house
def downloadDojo(thePath):
    """Download the Dojo JS toolkit"""
    DOJO_URL = "http://download.dojotoolkit.org/release-{0}/dojo-release-{0}.tar.gz".format(
        DOJO_VERSION)

    dojoFile = os.path.join(thePath,
                            "dojo-release-{0}.tar.gz".format(DOJO_VERSION))

    dojopath = os.path.join(thePath, "dojo")

    if os.path.exists(dojoFile):
        print "Dojo Exists"
    else:
        print "Downloading Dojo"
        urllib.urlretrieve(DOJO_URL, dojoFile)
        dojoTar = tarfile.open(dojoFile)
        dojoTar.extractall(thePath)

        #Overwrite any existing version
        if os.path.isdir(dojopath):
            print("Directory Exists")
            shutil.rmtree(dojopath)

        dojosource = os.path.join(thePath,
                                  "dojo-release-{0}".format(DOJO_VERSION))
        print "Source {0} Dest {1}".format(dojosource, dojopath)

        shutil.copytree(dojosource, dojopath)

    myWidget = os.path.join(dojopath, "MyWidgets")
    myexists = os.path.exists(myWidget)
    if not myexists:
        fullPath = os.path.join(myWidget, "form")
        os.makekdirs(fullPath)
        shutil.copy("cogentviewer/static/DateTimeBox.js", fullPath)

    #Then check for the dgrid etc modules
    dgridpath = os.path.join(dojopath, "dgrid")
    dexists = os.path.exists(dgridpath)
    print "Check for {0} {1}".format(dgridpath, dexists)

    if not dexists:
        print "No Dgrid"
        subprocess.call([
            "git", "clone", "https://github.com/SitePen/dgrid.git", dgridpath
        ])

    #And dgrid dependencies
    thepath = os.path.join(dojopath, "xstyle")
    exists = os.path.exists(thepath)
    print "Check for {0} {1}".format(thepath, exists)
    if not exists:
        print "No X Style"
        subprocess.call(
            ["git", "clone", "https://github.com/kriszyp/xstyle.git", thepath])

    thepath = os.path.join(dojopath, "put-selector")
    exists = os.path.exists(thepath)
    print "Check for {0} {1}".format(thepath, exists)
    if not exists:
        print "No Put Selector"
        subprocess.call([
            "git", "clone", "https://github.com/kriszyp/put-selector.git",
            thepath
        ])