Procházet zdrojové kódy

Added Config file elements for gatherMarket.py

KeyMasterOfGozer před 4 měsíci
rodič
revize
58dc99ea33
1 změnil soubory, kde provedl 17 přidání a 11 odebrání
  1. 17 11
      gatherMarket.py

+ 17 - 11
gatherMarket.py

@@ -4,6 +4,13 @@ import schedule
 import time
 from datetime import datetime
 from logger import logger
+from config import Config
+
+# Set Config Parameters
+MARKET_POLL_INTERVAL = Config["gather"].get("MarketPollInterval",15)
+PLAYER_POLL_INTERVAL = Config["gather"].get("PlayerPollInterval",15)
+CollectPlayerData = Config["gather"].get("CollectPlayer",False)
+Login = Config["gather"].get("Login",False)
 
 # Handle command arguments
 import argparse
@@ -12,7 +19,6 @@ parser.add_argument(
 	"-p",
 	"--player",
 	metavar="yes/no",
-	default='no',
 	choices=['yes','no'],
 	help="Collect player data?"
 	)
@@ -20,17 +26,17 @@ parser.add_argument(
 	"-l",
 	"--login",
 	metavar="yes/no",
-	default='no',
 	choices=['yes','no'],
 	help="Login to Browser?"
 	)
 args = parser.parse_args()
-CollectPlayerData = args.player
+if args.player is not None:
+    if args.player == 'yes': CollectPlayerData = True
+    else: CollectPlayerData = False
 login_yesno = args.login
-if login_yesno == 'yes':
-    Login = True
-else:
-    Login = False
+if args.login is not None:
+    if args.login == 'yes': Login = True
+    else: Login = False
 
 m=Market(login=Login)
 p=Player()
@@ -39,7 +45,7 @@ perr=0
 
 
 def jobM():
-    global m
+    global m,merr
     logger.info("Gathering Market Data.")
     try:
         m.fetchData()
@@ -53,7 +59,7 @@ def jobM():
             m=Market()
 
 def jobP():
-    global p
+    global p,perr
     logger.info("Gathering Player Data.")
     try:
         p.fetchData()
@@ -66,11 +72,11 @@ def jobP():
             perr=0
             p=Player()
 
-schedule.every(15).minutes.do(jobM)
+schedule.every(MARKET_POLL_INTERVAL).minutes.do(jobM)
 jobM()
 
 if CollectPlayerData == 'yes':
-    schedule.every(15).minutes.do(jobP)
+    schedule.every(PLAYER_POLL_INTERVAL).minutes.do(jobP)
     jobP()
 
 while 1: