forked from Rockyzsu/stock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
231 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
#-*-coding=utf-8-*- | ||
import os | ||
import tushare as ts | ||
from loguru import logger | ||
import requests | ||
import config | ||
|
||
def changeDir(): | ||
cwnd = os.getcwd() | ||
os.chdir(os.path.join(cwnd, 'data')) | ||
class BaseService: | ||
|
||
def __init__(self, logfile='default.log'): | ||
self.logger = logger | ||
self.logger.add(logfile) | ||
|
||
def check_path(self, path): | ||
if not os.path.exists(path): | ||
try: | ||
os.makedirs(path) | ||
except Exception as e: | ||
self.logger.error(e) | ||
|
||
def get_filename(self, url): | ||
return url.split('/')[-1] | ||
|
||
def notify(self,text): | ||
url = f"https://sc.ftqq.com/{config.WECHAT_ID}.send?text=" + text | ||
try: | ||
res = requests.get(url) | ||
except Exception as e: | ||
print(e) | ||
return False | ||
else: | ||
return True | ||
|
||
def save_iamge(self, content, path): | ||
with open(path, 'wb') as fp: | ||
fp.write(content) | ||
|
||
def get(self,url): | ||
raise NotImplemented | ||
|
||
def post(self): | ||
raise NotImplemented | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.