Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

Commit

Permalink
[~] Исправление проблемы с bulk_logger
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgspb committed Feb 20, 2018
1 parent 05e495e commit f38b6a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
11 changes: 10 additions & 1 deletion metaappscriptsdk/examples/bulk_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@

META = MetaApp()

# Станартный вариант
# Самый простой вариант без знания об общем количестве элементов
bulk_log = META.bulk_log(u'Моя пачка')
for idx in range(100):
if bulk_log.try_log_part():
print(u"bulk_log.get_percent_done() = %s" % str(bulk_log.get_percent_done()))
time.sleep(1)
bulk_log.finish()


# Стандартный вариант
total = 125
bulk_log = META.bulk_log(u'Моя пачка', total, 1)

Expand Down
2 changes: 1 addition & 1 deletion metaappscriptsdk/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.5.25'
__version__ = '0.5.26'
__package_name__ = 'metaappscriptsdk'

if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions metaappscriptsdk/logger/bulk_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@


class BulkLogger:
def __init__(self, log, log_message, total, part_log_time_minutes):
def __init__(self, log, log_message, total=None, part_log_time_minutes=1):
self.__log = log
self.__begin_time = time.time()

self.__log_message = log_message
self.__part_log_time_seconds = part_log_time_minutes * 60
self.__counter = 0

if total <= 0:
self.__log.info('Нет элементов для логирования. Вероятно список массив пустой')
total = None
if total is not None:
if total <= 0:
self.__log.info('Нет элементов для логирования. Вероятно список массив пустой')
total = None

self.__total = total
self.__percent_done = 0
Expand Down

0 comments on commit f38b6a0

Please sign in to comment.