-
Notifications
You must be signed in to change notification settings - Fork 3
Python Management Commands
Siqi Tian edited this page Feb 5, 2017
·
1 revision
Contains Django management command scripts.
- Backs up static files, MySQL, Apache, and local
config/files intobackup/folder. - Uses subprocess.check_call() for
mysqldump,tarfile for creating TGZ files. - Due to lack of permissions of www-data user to
/etc/apache2/, Apache settings are archived by acronjob under ubuntu. - The
cronjob is triggered weekly. Summary is sent to admin after job finish either via email.
- Checks if anyone's birthday is today and sends out wishes in Slack. Alumni members are excluded.
- The cron job is triggered daily.
- Caches analytics data into
cache/. Accepts an interval argument for category, choose from: 3, 15, or 30. - Results are saved as *.json and *.pickle files as a memory dump of variable. HTTP errors (500, 502, 503, connection time-out) are reported to Slack but with exemption.
- The cron job is triggered every 3, 15, 30 minutes.
- Checks if any duty reminders should be sent out today. Accepts an interval argument for category, choose from: week, month, or quarter.
- Dropbox and GitHub payment notice is sent on October annually.
- Birthday reminder includes people's birthdays for the upcoming 60 days.
- In DEBUG mode, all Slack messages will be sent to admin instead of original receiver.
- The weekly cron job is triggered daily to capture the 2 reminder dates. The monthly and quarterly cron jobs are also triggered daily, but only executed fully on first week of each month and the set date. Because checking time inside
pythonis easier than coding inbash.
- Uploads most recent backup onto
daslabGoogle Drive and cleans up obsolete backup files. - Uses subprocess.check_call() for
drive. Files are renamed with date as prefix. - Old files are determined by their last modified date and removed (default 45 days).
- The
cronjob is triggered weekly. Summary is sent to admin after job finish either via email or Slack.
- Sets up Flash Slides and sends out Group Meeting Reminder.
- Only on weeks that are not N/A will Flash Slides be created. Instead of creating a Google Presentation, it actually copies over an existing blank one specified by TEMPLATE_PRESENTATION_ID in
config/oauth.conf, because it's easier this way to have the aspect ratio correct. - The Group Meeting Reminder describes the meeting this week, next week, as well as headers and footers. Presenters' names will be matched by find_slack_id() in
src/console.py, and addressed in the message. - Admin will be notified for adding MySQL entries for
Eterna Special, Journal Club, and Rotation Student. Presenter of next week will be notified for preparation. - In DEBUG mode, all Slack messages will be sent to admin instead of original receiver.
- The cron job is triggered daily, but only executed fully on day before meeting. Because checking time inside
pythonis easier than coding inbash.
- Sends cron error report to admin if not IS_SLACK. Also compresses cron log and cleans up old Slack Messages.
- It zips
cache/log_cron.log, and removes Slack Messages that are older than 15 days in MySQL database. - The cron job is triggered weekly. Summary of
cache/log_alert_admin.logis sent to admin after job finish either via email or Slack.
- Restores static files, MySQL, Apache, and local
config/files from localbackup/files. - Uses subprocess.check_call() for
mysql,tarfileandshutilfor unpacking TGZ files.
- Collects system installed package versions into
cache/stat_sys.jsonandcache/stat_ver.json. Accepts a flag argument for overriding IS_VERSIONS inconfig/bot.conf, chooses from: 0 or 1. - Retrieves SSL Certificate expiration date by calling dash_ssl() from
src/dash.py. - Uses subprocess.Popen() for
bashcommands. Some commands need to write tocache/temp.txttemporarily for output handling. Some values, e.g. WebAuth, mod_wsgi, and wallet are implemented for production only. Commands for memory readings are dependent onDEBUGas well. - Renders
cache/sys_ver.txt(only in production) based on information incache/stat_ver.json. It is displayed inbashupon login. - Calls get_backup_stat() from
src/console.pytoo.
New Admin Setup
Admin Responsibility
Server Environment
Overview
Linux
Python