소스 검색

Improve code with time

JoostSijm 5 년 전
부모
커밋
31520bb348
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      hvs/__main__.py

+ 4 - 2
hvs/__main__.py

@@ -5,7 +5,8 @@ import random
 import time
 
 from hvs import scheduler
-from hvs.app import download_resources, need_refill, max_refill_seconds, refill, save_resources, print_resources
+from hvs.app import download_resources, need_refill, max_refill_seconds, refill, \
+    save_resources, print_resources
 
 
 def job_check_resources(state_id, capital_id, resource_id):
@@ -15,7 +16,8 @@ def job_check_resources(state_id, capital_id, resource_id):
     print_resources(regions)
     if need_refill(regions, 25):
         max_seconds = max_refill_seconds(regions, 25, 900) 
-        random_time = timedelta(seconds=random.randint(0, max_seconds))
+        random_seconds = random.randint(0, max_seconds)
+        random_time = timedelta(seconds=random_seconds)
         scheduled_date = datetime.now() + random_time
         job_id = 'refill_{}_{}'.format(capital_id, resource_id)
         print('refill resource: {} at {} ({} minutes)'.format(