Skip to content

Commit

Permalink
Add config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tychxn committed Feb 17, 2019
1 parent 059368b commit 7ee8da1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
import os

import configparser


class Config(object):
def __init__(self, config_file='config.ini'):
self._path = os.path.join(os.getcwd(), config_file)
if not os.path.exists(self._path):
raise FileNotFoundError("No such file: config.ini")
self._config = configparser.ConfigParser()
self._config.read(self._path)

def get(self, section, name):
return self._config.get(section, name)


global_config = Config()
2 changes: 1 addition & 1 deletion timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def start(self):
now_time = datetime.now
while True:
if now_time() >= self.buy_time:
print(get_current_time(), '时间达到,开始执行……')
print(get_current_time(), '时间到达,开始执行……')
break
else:
time.sleep(self.sleep_interval)

0 comments on commit 7ee8da1

Please sign in to comment.