Example #1
0
def main(argv):
    import getopt
    user = '******'
    password = ''
    if password == '':
        import getpass
        password = getpass.getpass()

    #openShareFolder(user, password)
    #path = r'\\10.58.0.100\Root\Business_One\Projects\Dev\SDK\KnowledgeWarehouse\_Ebook\java'
    # path = r'//CNST50066074/Root/Business_One/Projects/Dev/SDK/KnowledgeWarehouse/_Ebook/java/m2ebook-pdf.pdf'
    path = r'//pvgn50863254a/share/DOCTEST/newdoc.doc'
    from fetchFile import FetchFile
    fetcher = FetchFile(path, user, password)  #openShareFolder()
    # try:
    s, url, fileType = fetcher.fetchData()
    print type(s)
    print s
    print 'code: ', fetcher.getResponseCode()
    parser = ParserDOCX()
    dicIn = {ParseInputDS.RAWDATA: s}
    outpath = parser.parseContent(dicIn)
    print 'out file:', outpath

    # except Exception as e:
    #     # print 'exception.....', str(e)
    #     raise e
    # s = fetcher.fetchData()
    # print type(s)
    # print s
    print 'code: ', fetcher.getResponseCode()
Example #2
0
def main(argv):
	import getopt
	user = '******'
	password = ''
	if password == '':
		import getpass
		password = getpass.getpass()

	#openShareFolder(user, password)
	#path = r'\\10.58.0.100\Root\Business_One\Projects\Dev\SDK\KnowledgeWarehouse\_Ebook\java'
	# path = r'//CNST50066074/Root/Business_One/Projects/Dev/SDK/KnowledgeWarehouse/_Ebook/java/m2ebook-pdf.pdf'
	path = r'//pvgn50863254a/share/DOCTEST/newdoc.doc'
	from fetchFile import FetchFile
	fetcher = FetchFile(path, user, password) #openShareFolder()
	# try:
	s, url, fileType = fetcher.fetchData()
	print type(s)
	print s
	print 'code: ',fetcher.getResponseCode()
	parser = ParserDOCX()
	dicIn = {ParseInputDS.RAWDATA:s}
	outpath = parser.parseContent(dicIn)
	print 'out file:', outpath

	# except Exception as e:
	#     # print 'exception.....', str(e)
	#     raise e
	# s = fetcher.fetchData()
	# print type(s)
	# print s
	print 'code: ',fetcher.getResponseCode()
Example #3
0
def main(argv):
    import getopt

    def usage():
        print("usage: %s [-u user] [-p password] [-d dir]"
              " file ..." % argv[0])
        return 100

    try:
        opts, args = getopt.getopt(argv[1:], "ho:v",
                                   ["user="******"password="******"dir="])
    except getopt.GetoptError as err:
        print str(err)
        return usage()
    #print opts
    if not opts: return usage()
    user = ""
    password = ""
    dir = ''
    print 'opts', opts
    for (k, v) in opts:
        if k in ("-u", "--user"): user = v
        elif k in ("-p", "--password"): password = v
        elif k in ('-d', "--dir"): dir = v
    if password == '':
        import getpass
        # password = getpass.getpass()
        password = "******"

    #openShareFolder(user, password)
    #path = r'\\10.58.0.100\Root\Business_One\Projects\Dev\SDK\KnowledgeWarehouse\_Ebook\java'
    path = r'//CNST50066074/Root/Business_One/Projects/Dev/SDK/KnowledgeWarehouse/_Ebook/java/m2ebook-pdf.pdf'
    from fetchFile import FetchFile
    fetcher = FetchFile(path, user, password)  #openShareFolder()
    # try:
    s = fetcher.fetchData()
    print type(s)
    print s
    print 'code: ', fetcher.getResponseCode()
    parser = ParserPDF()
    dicIn = {ParseInputDS.RAWDATA: s}
    outpath = parser.parseContent(dicIn)
    print 'out file:', outpath

    # except Exception as e:
    #     # print 'exception.....', str(e)
    #     raise e
    # s = fetcher.fetchData()
    # print type(s)
    # print s
    print 'code: ', fetcher.getResponseCode()
Example #4
0
def main(argv):
	import getopt
	def usage():
		print ("usage: %s [-u user] [-p password] [-d dir]"
			   " file ..." % argv[0])
		return 100

	try:
		opts, args = getopt.getopt(argv[1:], "ho:v", ["user="******"password="******"dir="])
	except getopt.GetoptError as err:
		print str(err)
		return usage()
	#print opts
	if not opts: return usage()
	user = ""
	password = ""
	dir = ''
	print 'opts', opts
	for (k, v) in opts:
		if k in ("-u", "--user") : user = v
		elif k in ("-p", "--password") : password = v
		elif k in ('-d', "--dir") : dir = v
	if password == '':
		import getpass
		# password = getpass.getpass()
		password = "******"

	#openShareFolder(user, password)
	#path = r'\\10.58.0.100\Root\Business_One\Projects\Dev\SDK\KnowledgeWarehouse\_Ebook\java'
	path = r'//CNST50066074/Root/Business_One/Projects/Dev/SDK/KnowledgeWarehouse/_Ebook/java/m2ebook-pdf.pdf'
	from fetchFile import FetchFile
	fetcher = FetchFile(path, user, password) #openShareFolder()
	# try:
	s = fetcher.fetchData()
	print type(s)
	print s
	print 'code: ',fetcher.getResponseCode()
	parser = ParserPDF()
	dicIn = {ParseInputDS.RAWDATA:s}
	outpath = parser.parseContent(dicIn)
	print 'out file:', outpath

	# except Exception as e:
	#     # print 'exception.....', str(e)
	#     raise e
	# s = fetcher.fetchData()
	# print type(s)
	# print s
	print 'code: ',fetcher.getResponseCode()
Example #5
0
def getFetcher(addr, uid, upwd):

    urlType = 0  # Default:0:Wiki 1:Jam 2:network_path
    if re.search(WIKI, str(addr)):
        urlType = WIKI_TYPE
    elif re.search(JAM, str(addr)):
        urlType = JAM_TYPE
    elif addr.startswith(NETWORK_PATH):
        urlType = NETWORK_PATH_TYPE

    if urlType == WIKI_TYPE:
        return FetchWikiData(addr, uid, upwd)
    elif urlType == JAM_TYPE:
        return FetchJamData(addr, uid, upwd)
    elif urlType == NETWORK_PATH_TYPE:
        return FetchFile(addr, uid, upwd)
    else:
        raise Exception('unknow link type')