-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhb_report.py
66 lines (55 loc) · 1.7 KB
/
hb_report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# coding=utf-8
import pprint
import click
import os
import subprocess
import glob
import time
import sys
import datetime
import re
def is_bad_date(filename_regex, newest):
today_date = datetime.datetime.now().strftime('%y%m%d')
try:
newest_date = re.search(filename_regex, newest).group(1)
except AttributeError:
newest_date = ''
if newest_date != today_date:
print('Error: newest date != today date.. mannual intervention needed..')
return True
print('newest date: ' + newest_date)
return False
def is_bad_date_re(filename_regex, newest):
today_date = datetime.datetime.now().date()
try:
newest_date = re.search(filename_regex, newest).group(1)
except AttributeError:
newest_date = ''
try:
newest_date = datetime.datetime.strptime(newest_date , '%y%m%d').date()
except ValueError:
print('Error: Unable to convert date')
return True
if newest_date < today_date:
print('Error: newest date < today date.. mannual intervention needed..')
return True
print('newest date: ' + str(newest_date))
return False
# hua shi shui jiao
def hua_style_sleep():
for i in range(3):
print('sleeping..' + str(i))
time.sleep(1)
@click.command()
def hb_report():
subprocess.call(['python', 'sendmail_win_hb.py', '--days', '-1'])
hua_style_sleep()
newest = max(glob.iglob('CTRIP---API-Errors---API-valuation-step-issues*.csv'), key=os.path.getctime)
print('Using.. ' + newest)
subprocess.call(['python', 'hb_er.py', '--filename', newest])
# subprocess.call(['python', 'search_item_hr.py', '--filename', newest])
hua_style_sleep()
subprocess.call(['python', 'sendmail_win_hb2.py'])
if __name__ == '__main__':
hb_report()