本文整理匯總了Python中importer.Importer.start方法的典型用法代碼示例。如果您正苦於以下問題:Python Importer.start方法的具體用法?Python Importer.start怎麽用?Python Importer.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類importer.Importer
的用法示例。
在下文中一共展示了Importer.start方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: from importer import Importer [as 別名]
# 或者: from importer.Importer import start [as 別名]
def start(path, username, password):
rest = RestClient(username)
webdav = WebDav(username, password)
login_attempts = 0
if not rest.login(username, password):
login_attempts += 1
print("Invalid username or password." + username)
if login_attempts < 5:
start()
else:
exec(1)
log = logging.getLogger("lims_import")
log.setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setLevel(logging.DEBUG)
fh = logging.FileHandler("lims-import.log")
fh.setLevel(logging.DEBUG)
fh.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] \t %(message)s"))
log.addHandler(sh)
log.addHandler(fh)
if not webdav.is_available():
log.error("Unable to connect to Owncloud.")
exit(1)
for project in path:
if not os.path.exists(project):
log.error("{} not found.".format(project))
exit(1)
total = 0
for project in path:
total += 1
for root, dirs, files in os.walk(project):
total += len(files)
total += len(dirs)
bar = progressbar.ProgressBar(max_value=total, redirect_stdout=True)
def update_progress():
bar.update(bar.value + 1)
importer = Importer(username, password)
importer.on_update += update_progress
for project in path:
importer.start(project)