예제 #1
0
#optional: useful if you want to choose the logging level to something else than logging.WARN
import sys, os
import logging

try:  #to ease the use without proper Python installation
    import TranskribusPyClient_version
except ImportError:
    sys.path.append(
        os.path.dirname(
            (os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))))))
    import TranskribusPyClient_version

from TranskribusPyClient.test import _colId_A, _docId_b
from TranskribusPyClient.client import TranskribusClient, getStoredCredentials

login, pwd = getStoredCredentials()

conn = TranskribusClient(proxies={'https': 'http://*****:*****@xrce.xerox.com", "trnjluc", sHttpsProxyUrl='http://cornillon:8000')

sXml = u"""<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PcGts xmlns="http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15 http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15/pagecontent.xsd">
    <Metadata>
    __Trnskrbs_basic_options(parser, DoLogin.sDefaultServerUrl)

    #parse the command line
    (options, args) = parser.parse_args()

    # ---
    #credentials and proxy
    proxies = {} if not options.https_proxy else {
        'https_proxy': options.https_proxy
    }

    if options.login:
        login, pwd = options.login, options.pwd
    else:
        trace("- no login provided, looking for stored credentials... ")
        login, pwd = getStoredCredentials(bAsk=False)
        traceln("OK")

    # ------------------------------------------------------------------------------------------------

    doer = DoLogin(options.server, proxies, loggingLevel=logging.INFO)

    try:
        if options.persist:
            traceln(
                "- Logging onto Transkribus as %s and making a persistent session"
                % login)
            doer.cleanPersistentSession()
            resp = doer.auth_login(login, pwd, bPersist=options.persist)
            traceln("\t --> %s" % os.path.join(DoLogin._sSESSION_FOLDER,
                                               DoLogin._sSESSION_FILENAME))