Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 5, 2019. It is now read-only.

Commit 2117144

Browse files
committed
add commandline argument support
1 parent 3a6a638 commit 2117144

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

‎1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
3+
print sys.argv[1]
4+

‎README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ First clone this repository and then follow the given steps below :-
1010
### Prerequisites
1111
You need to have a google account to do this and the rest are specified under getting started itself
1212
## Running the script
13-
You can directly use python <filename> and if are using python3 make sure that you edit print functions enclosing with () in files test.py and email_checker.py
13+
```python
14+
python email_checker.py '14/02/2018'
15+
```
1416

1517
## Built with
1618
Python

‎email_checker.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1+
import sys
12
import test
23
import csv
34

5+
6+
date = sys.argv[1]
7+
48
cs = open('data/1.csv', 'r')
59
y1 = []
610
y2 = []
711
y3 = []
812
y4 = []
913
y = []
14+
1015
y1.append(10 * "-" + 'FIRST YEARS' + 10 * "-")
1116
y2.append(10 * "-" + 'SECOND YEARS' + 10 * "-")
1217
y3.append(10 * "-" + 'THIRD YEARS' + 10 * "-")
1318
y4.append(10 * "-" + "FOURTH YEARS" + 10 * "-")
14-
message = test.main()
1519

16-
print ("Number of status mails %d" %len(message))
20+
message = test.main(date)
21+
22+
print ("Number of status mails %d" % len(message))
1723

1824
with cs:
1925
wcs = csv.reader(cs)

‎test.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
email_list = []
1212

13-
try:
14-
import argparse
15-
16-
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
17-
except ImportError:
18-
flags = None
13+
# try:
14+
# import argparse
15+
#
16+
# flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
17+
# except ImportError:
18+
# flags = None
1919

2020
# If modifying these scopes, delete your previously saved credentials
2121
# at ~/.credentials/gmail-python-quickstart.json
@@ -156,19 +156,15 @@ def ListMessagesMatchingQuery(service, user_id, query=''):
156156
print ('An error occurred: %s' % error)
157157

158158

159-
def main():
159+
def main(date):
160160
# This is the function which asks the user for his query
161161
credentials = get_credentials()
162162
http = credentials.authorize(httplib2.Http())
163163
service = discovery.build('gmail', 'v1', http=http)
164-
a = raw_input("enter the date : ")
165-
a = '[foss-2017] Status Update [' + a + ']'
164+
query = '[foss-2017] Status Update [' + date + ']'
166165
message = []
167-
messgs = ListMessagesMatchingQuery(service, user_id='me', query=a)
166+
messgs = ListMessagesMatchingQuery(service, user_id='me', query=query)
168167
for item in messgs:
169168
message = GetMsg(service, user_id="me", msg_id=item['id'])
170169
return message
171170

172-
173-
if __name__ == '__main__':
174-
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /