Skip to content

Commit 5ff172a

Browse files
committed
Locally specify paths to roster and pswd
1 parent a23ec46 commit 5ff172a

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ Create a conda environment with all dependencies:
1717

1818
## Running
1919

20-
1. Specify the URLs that you'd like to track (and optionally, their options) by
21-
editing `roster.json`; see `roster.json.example`.
20+
1. Specify the URLs that you'd like to track (and optional URL-specific
21+
arguments) by editing `./roster.json`.
2222

23-
1. Edit `gmail_app_pswd`, with its content being your Gmail app-specific password
24-
(a Gmail-only password; see how to set one up [here](https://support.google.com/accounts/answer/185833?hl=en)).
23+
1. Create a file `./gmail_app_pswd`, with its content being your Gmail
24+
*app-specific* password (NOT your Google account password; see how to set one
25+
up [here](https://support.google.com/accounts/answer/185833?hl=en)).
2526

2627
1. Activate the environment and run the monitor:
2728

gmail_app_pswd

-1
This file was deleted.

main.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
FLAGS = flags.FLAGS
1717
flags.DEFINE_string('roster_json', './roster.json', 'path to the roster')
18-
flags.DEFINE_string('gmail', 'xiuming6zhang@gmail.com', 'email address')
18+
flags.DEFINE_string('gmail', 'xiuming6zhang@gmail.com', 'Gmail address')
19+
flags.DEFINE_string('gmail_pswd_path', './gmail_app_pswd',
20+
'Gmail app-specific password')
1921
flags.DEFINE_integer('check_every', 43200, 'check every N seconds')
2022
flags.DEFINE_integer('exit_after', None, 'quit after N seconds')
2123
flags.DEFINE_string('snapshot_dir', './snapshots',
@@ -71,7 +73,10 @@ def main(_):
7173
msg = ''
7274
for url, delta in zip(changed, deltas):
7375
msg += f'------\n{url}\n\n{delta}\n\n\n'
74-
util.email_oneself(msg, FLAGS.gmail, subject='Webpage Monitor')
76+
util.email_oneself(msg,
77+
FLAGS.gmail,
78+
gmail_pswd_path=FLAGS.gmail_pswd_path,
79+
subject='Webpage Monitor')
7580

7681
logging.info('Change detected; email sent')
7782
else:

roster.json

-1
This file was deleted.

roster.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"https://xiuming.info/": {},
3+
"https://www.weizmann.ac.il/math/dekel/publications-0": {
4+
"ignore_prefix": [
5+
"<script>jQuery.extend",
6+
"<script id=\"f5_cspm\">"
7+
]
8+
}
9+
}

roster.json.example

-10
This file was deleted.

util.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ def folder_name_from_url(url):
2323
return folder_name
2424

2525

26-
def email_oneself(msg, gmail, subject='Untitled', pswd_path='./gmail_app_pswd'):
27-
pswd = read_file(pswd_path)
26+
def email_oneself(msg,
27+
gmail,
28+
gmail_pswd_path='./gmail_app_pswd',
29+
subject='Untitled'):
30+
pswd = read_file(gmail_pswd_path)
2831
pswd = pswd.strip()
2932

3033
to_emails = [gmail]

0 commit comments

Comments
 (0)