loggingLevel=logging.WARN):
        TranskribusClient.__init__(self,
                                   sServerUrl=self.sDefaultServerUrl,
                                   proxies=sHttpProxy,
                                   loggingLevel=loggingLevel)


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, listPageLocks.sDefaultServerUrl)

    # ---
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    # ---
    #source collection(s)
    try:
        colid = int(args[0])
    except Exception as e:
        _exit(usage, 1, e)
    try:
示例#2
0
                 loggingLevel=logging.WARN):
        TranskribusClient.__init__(self,
                                   sServerUrl=self.sDefaultServerUrl,
                                   proxies=sHttpProxy,
                                   loggingLevel=loggingLevel)


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoDeleteJob.sDefaultServerUrl)

    # ---
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    # ---
    #source collection(s)
    try:
        jobid = int(args[0])
    except Exception as e:
        _exit(usage, 1, e)
示例#3
0
                 loggingLevel=logging.WARN):
        TranskribusClient.__init__(self,
                                   sServerUrl=self.sDefaultServerUrl,
                                   proxies=sHttpProxy,
                                   loggingLevel=loggingLevel)


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoCopyDocToCollec.sDefaultServerUrl)

    # ---
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    # ---
    #source collection
    try:
        colIdFrom = int(args.pop(0))
    except Exception as e:
        _exit(usage, 1, e)
    #target collection
    def __init__(self, trnkbsServerUrl, sHttpProxy=None, loggingLevel=logging.WARN):
        TranskribusClient.__init__(self, sServerUrl=self.sDefaultServerUrl, proxies=sHttpProxy, loggingLevel=loggingLevel)
    
    def run(self, colId, docId, nrOfTranscripts=1):
        ret = self.getDocById(colId, docId, nrOfTranscripts)
        return ret

if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description
    
    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoGetDocTrp.sDefaultServerUrl)
    parser.add_option("-n", "--n"  , dest='nbTranscript', action="store", type="int", default=1, help="Number of transcripts")
        
    # ---   
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {'https_proxy':options.https_proxy}

    # --- 
    doer = DoGetDocTrp(options.server, proxies, loggingLevel=logging.WARN)
    __Trnskrbs_do_login_stuff(doer, options, trace=trace, traceln=traceln)
    # --- 
    try:                        colId = int(args.pop(0))
    except Exception as e:      _exit(usage, 1, e)
    try:                        docId   = int(args.pop(0))
    except Exception as e:      _exit(usage, 1, e)
示例#5
0
    
    #--- INIT -------------------------------------------------------------------------------------------------------------    
    def __init__(self, trnkbsServerUrl, sHttpProxy=None, loggingLevel=logging.WARN):
        TranskribusClient.__init__(self, sServerUrl=self.sDefaultServerUrl, proxies=sHttpProxy, loggingLevel=loggingLevel)
        
        

if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description
    
    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoGetJobs.sDefaultServerUrl)
        
    # ---   
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {'https_proxy':options.https_proxy}

    # --- 
    #source collection(s)
#     try:
#         jobid = int(args[0])
#     except Exception as e:
#         _exit(usage, 1, e)

    # --- 
    doer = DoGetJobs(options.server, proxies, loggingLevel=logging.INFO)
        regId.text = ''
        nodep.append(pageId)
        nodep.append(tsId)
        nodep.append(regId)

    print(etree.tostring(xmldesc, pretty_print=True, encoding='utf-8'))


if __name__ == '__main__':
    version = "v.01"
    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoLAbatch.sDefaultServerUrl)

    parser.add_option("--trp",
                      dest='trp_doc',
                      action="store",
                      type="string",
                      default=None,
                      help="use trp doc file")
    parser.add_option("--doRegionSeg",
                      dest='doRegionSeg',
                      action="store_true",
                      default=False,
                      help="do Region detection")
    parser.add_option("--batchjob",
                      dest='doBatchJob',
                      action="store_true",
示例#7
0
                "regionIds": []
            })


#         return jsonDesc["docId"], json.dumps(jsonDesc,encoding='utf-8')
        return jsonDesc["docId"], json.dumps(jsonDesc)

if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoHtrRnn.sDefaultServerUrl)

    parser.add_option("-r",
                      "--region",
                      dest='region',
                      action="store",
                      type="string",
                      default=DoHtrRnn.sDefaultServerUrl,
                      help="apply HTR at region level")
    parser.add_option("--trp",
                      dest='trp_doc',
                      action="store",
                      type="string",
                      default=None,
                      help="use trp doc file")
    parser.add_option("--docid",
#         else:
#             #JLM - April 2009 - dump does not support the compressiondoc.dump(self.getOutputFile())
#             doc.saveFileEnc(self.getOutputFileName(),"UTF-8")

if __name__ == '__main__':
    usage = "%s [-f|--force] [--strict] [--docid <id>] [--trp <trp_file>] [--noImage] <colid> [<directory>]" % sys.argv[
        0]
    version = "v.03"
    description = "Extract a collection from transkribus and create a DS test structure containing that collection. \n" + _Trnskrbs_description

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, TranskribusDownloader.sDefaultServerUrl)

    parser.add_option(
        "-f",
        "--force",
        dest='bForce',
        action="store_true",
        default=False,
        help=
        "Force rewrite if disk data is obsolete, or force overwrite in --trp mode"
    )
    parser.add_option("--strict",
                      dest='bStrict',
                      action="store_true",
                      default=False,
                      help="Failed schema validation stops the processus.")
                page['tsList']['transcripts'][0]['tsId'],
                "regionIds": []
            })


#         return jsonDesc["docId"], json.dumps(jsonDesc,encoding='utf-8')
        return jsonDesc["docId"], json.dumps(jsonDesc)

if __name__ == '__main__':
    version = "v.01"
    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoTableTemplate.sDefaultServerUrl)

    parser.add_option("--trp",
                      dest='trp_doc',
                      action="store",
                      type="string",
                      default=None,
                      help="use trp doc file")
    parser.add_option("--templateID",
                      dest='templateID',
                      action="store",
                      type="string",
                      help="template id")
    #     parser.add_option("--batchjob"  , dest='doBatchJob'   , action="store_true",  default=False, help="do one job per page")

    # ---
            strTabularFormat(lDic, [
                "modelName", "modelId", "isUsableInTranskribus", "nrOfTokens",
                "nrOfDictTokens", "nrOfLines"
            ], "modelName"))
        return lDic


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoListHtrModels.sDefaultServerUrl)

    # ---
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    # ---
    doer = DoListHtrModels(options.server, proxies, loggingLevel=logging.WARN)
    __Trnskrbs_do_login_stuff(doer, options, trace=trace, traceln=traceln)

    # ---
    # do the job...
    doer.run()
示例#11
0
                print(">> (%s) #p=%d  '%s' by %s  (status=%s)" %
                      (dic[u'docId'], dic[u'nrOfPages'], dic[u'title'],
                       dic[u'uploader'], dic[u'status']))
        else:
            print(">> Collection is empty!")


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoListCollec.sDefaultServerUrl)

    # ---
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    # ---
    #source collection(s)
    try:
        lColId = [int(arg) for arg in args]
    except Exception as e:
        _exit(usage, 1, e)
示例#12
0
def main():
    usage = "%s <directory> <coldId> [<docId>]" % sys.argv[0]
    version = "v.01"
    description = """Upload the transcript(s) from the DS structure to Transkribus, either of the collection or one of its document(s). 
The <directory> must have been created by transkribus_downloader.py and should contain the 'col' directory and a trp.json file for the collection, and one per document (the 'out', 'ref', 'run', 'xml' folders are not used).
The page transcript from the single page PageXml files are uploaded. (The multi-page xml file(s) are ignored))    
""" + _Trnskrbs_description

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser,
                             TranskribusTranscriptUploader.sDefaultServerUrl)

    parser.add_option("-q",
                      "--quiet",
                      dest='bQuiet',
                      action="store_true",
                      default=False,
                      help="Quiet mode")
    parser.add_option("--trp",
                      dest='trp',
                      action="store",
                      type="string",
                      help="download the content specified by the trp file.")
    parser.add_option("--toolname",
                      dest='tool',
                      action="store",
                      type="string",
                      default="",
                      help="Set the Toolname metadata in Transkribus.")
    parser.add_option("--message",
                      dest='message',
                      action="store",
                      type="string",
                      default="",
                      help="Set the message metadata in Transkribus.")
    parser.add_option("--set_status",
                      dest='set_status',
                      action="store",
                      type="string",
                      default=None,
                      help="Set the status of the uploaded trasnscript.")

    # ---
    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    iVerbose = 0 if options.bQuiet else 2
    # ---
    try:
        sDSDir = args.pop(0)
    except:
        _exit(usage, 1)
    if not (sDSDir.endswith(sCOL) or sDSDir.endswith(sCOL + os.path.sep)):
        sColDSDir = os.path.abspath(os.path.join(sDSDir, sCOL))
    else:
        sColDSDir = os.path.abspath(sDSDir)
    if not (os.path.exists(sColDSDir) and os.path.isdir(sColDSDir)):
        raise ValueError("Non-existing folder: %s " % sColDSDir)

    try:
        colid = args.pop(0)
    except:
        _exit(usage, 1)

    try:
        docid = args.pop(0)
    except:
        docid = None

    # ---
    doer = TranskribusTranscriptUploader(options.server,
                                         proxies,
                                         loggingLevel=logging.WARN)
    __Trnskrbs_do_login_stuff(doer, options, trace=trace, traceln=traceln)

    if options.trp:
        trp = json.load(open(options.trp, "r", encoding='utf-8'))
        traceln("- Uploading to collection %s, as specified by trp data" %
                (colid))
        if not docid:
            docid = trp["md"]["docId"]
            traceln(" read docId from TRP: docId = %s" % docid)
        sToolname = options.tool if options.tool else "Transkribus_uploader (--trp)"
        lFileList = doer.uploadDocumentTranscript_by_trp(
            colid,
            docid,
            trp,
            sColDSDir,
            sNote=options.message,
            sToolName=sToolname,
            iVerbose=iVerbose,
            status=options.set_status)
        #traceln(map(lambda x: x.encode('utf-8'), lFileList))
    else:
        if docid == None:
            sToolname = options.tool if options.tool else "Transkribus_uploader"
            doer.uploadCollectionTranscript(colid,
                                            sColDSDir,
                                            sNote=options.message,
                                            sToolName=sToolname,
                                            iVerbose=iVerbose,
                                            status=options.set_status)

        else:
            sToolname = options.tool if options.tool else "Transkribus_uploader (docid)"
            doer.uploadDocumentTranscript(colid,
                                          docid,
                                          sColDSDir,
                                          sNote=options.message,
                                          sToolName=sToolname,
                                          iVerbose=iVerbose,
                                          status=options.set_status)

    traceln('- DONE, all transcripts were uploaded. See in collection %s' %
            colid)
    assert (["/jdoe", "pierre"],
            ["paul"
             ]) == DoTranscript.splitPosNeg(["//jdoe", "/paul", "pierre"])


#--------------------------------------------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
    version = "v1.0"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoTranscript.sDefaultServerUrl)
    parser.add_option(
        "--last",
        dest='last',
        action="store_true",
        default=False,
        help=
        "filter (i.e. keep) only last transcript of each page before any filtering occurs."
    )
    parser.add_option(
        "--after",
        dest='after',
        action="store",
        type="string",
        default=None,
        help="filter (i.e. keep) transcripts created on or after this date.")
#         return lFileList

if __name__ == '__main__':
    usage = "%s <directory> <coldId> [<docId>]" % sys.argv[0]
    version = "v.01"
    description = """Upload the DU transcript(s) from the DS structure to Transkribus, either of all or one of its %s file(s) to the given collection. 
The <directory> is the usual DS one and should contain the 'col' directory (the 'out', 'ref', 'run', 'xml' are not used).
Extract the page transcript from the MultiPageXml (not from the single page PageXml files!)    
""" % sTRANSCRIPT_EXTENSION + _Trnskrbs_description

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser,
                             TranskribusDUTranscriptUploader.sDefaultServerUrl)

    parser.add_option("--strict",
                      dest='bStrict',
                      action="store_true",
                      default=False,
                      help="Failed schema validation stops the processus.")
    parser.add_option("--nodu",
                      dest='bNoDU',
                      action="store_true",
                      default=False,
                      help="Upload the non-DU transcript (the .mpxml one)")
    parser.add_option("-q",
                      "--quiet",
                      dest='bQuiet',
                      action="store_true",
示例#15
0
                 loggingLevel=logging.WARN):
        TranskribusClient.__init__(self,
                                   sServerUrl=_Trnskrbs_default_url,
                                   proxies=sHttpProxy,
                                   loggingLevel=loggingLevel)


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, DoLogout.sDefaultServerUrl)

    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }
    # ------------------------------------------------------------------------------------------------
    doer = DoLogout(options.server, proxies, loggingLevel=logging.INFO)
    try:
        __Trnskrbs_do_login_stuff(doer, options, trace=trace, traceln=traceln)
    except:
        pass

    try:
        traceln('- cleaning any persistent session.')
                 loggingLevel=logging.WARN):
        TranskribusClient.__init__(self,
                                   sServerUrl=_Trnskrbs_default_url,
                                   proxies=sHttpProxy,
                                   loggingLevel=loggingLevel)


if __name__ == '__main__':
    version = "v.01"

    #prepare for the parsing of the command line
    parser = OptionParser(usage=usage, version=version)
    parser.description = description

    #"-s", "--server",  "-l", "--login" ,   "-p", "--pwd",   "--https_proxy"    OPTIONS
    __Trnskrbs_basic_options(parser, _Trnskrbs_default_url)

    #parse the command line
    (options, args) = parser.parse_args()
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }
    # ------------------------------------------------------------------------------------------------
    doer = DoAddDocToCollec(options.server, proxies, loggingLevel=logging.INFO)
    __Trnskrbs_do_login_stuff(doer, options, trace=trace, traceln=traceln)

    # ---
    #target collection
    try:
        colId = int(args.pop(0))
    except Exception as e: