forked from sendgrid/open-source-library-data-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·39 lines (30 loc) · 1.05 KB
/
app.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
from db_connector import DBConnector, GitHubData, PackageManagerData
from config import Config
from github import GitHub
from package_managers import PackageManagers
from sendgrid_email import SendGrid
config = Config()
db = DBConnector()
github = GitHub()
pm = PackageManagers()
sg = SendGrid()
def update(send_email=True):
# Update the DB with the GitHub repo data
for repo in config.github_repos:
github.update_library_data(config.github_user, repo)
# Update the DB with Package Manager data
pm.update_package_manager_data(config.package_manager_urls)
# Export tables as CSV if config file indicates to do so
if config.export_github:
db.export_table_to_csv(GitHubData)
if config['export_tables']['PackageManagers']:
db.export_table_to_csv(PackageManagerData)
if not send_email:
return
# Send an email update
sg.send_email(config.to_email,
config.from_email,
config.email_subject,
config.email_body)
if __name__ == "__main__":
update()