APS-USAXS / usaxs-bluesky-ended-2023

Bluesky instrument for USAXS
0 stars 0 forks source link

test EmailNotifications code #67

Closed prjemian closed 5 years ago

prjemian commented 6 years ago

refs #48

prjemian commented 6 years ago

unix_cmd() seems to work:

In [1]: unix_cmd(["ls",])
Out[1]: 
(b'00-0-checks.py\n00-startup.py\n01-databroker.py\n02-pyepics.py\n09-imports.py\n10-devices.py\n11-motors.py\n20-detectors.py\n21-filters_shutters.py\n21-signals.py\n22-amplifiers.py\n24-detector_data_file_names.py\n24-zz_APS_devices.py\n25-alta.py\n25-blackfly.py\n25-pilatus.py\n25-simdetector.py\n29-axis_tuning.py\n32-usaxs_flyscan.py\n50-plans.py\n60-metadata.py\n79-callbacks-overrrides.py\n80-callbacks.py\nchecklist.md\ncore\nmongodb_config.yml\nnotebooks\nREADME\nREADME.md\nspec\nusaxs_support\n',
 b'')

In [2]: print(unix_cmd(["ls",]))
(b'00-0-checks.py\n00-startup.py\n01-databroker.py\n02-pyepics.py\n09-imports.py\n10-devices.py\n11-motors.py\n20-detectors.py\n21-filters_shutters.py\n21-signals.py\n22-amplifiers.py\n24-detector_data_file_names.py\n24-zz_APS_devices.py\n25-alta.py\n25-blackfly.py\n25-pilatus.py\n25-simdetector.py\n29-axis_tuning.py\n32-usaxs_flyscan.py\n50-plans.py\n60-metadata.py\n79-callbacks-overrrides.py\n80-callbacks.py\nchecklist.md\ncore\nmongodb_config.yml\nnotebooks\nREADME\nREADME.md\nspec\nusaxs_support\n', b'')

In [3]: unix_cmd(["ls","-larth"])
Out[3]: 
(b'total 804K\n-rw-rw-r-- 1 usaxs usaxs 1.2K Jan  8  2018 01-databroker.py\n-rw-rw-r-- 1 usaxs usaxs  128 Jan  8  2018 02-pyepics.py\n-rw-rw-r-- 1 usaxs usaxs  732 Jan  8  2018 README.md\n-rw-rw-r-- 1 usaxs usaxs  371 Jan  9  2018 README\n-rw-rw-r-- 1 usaxs usaxs  464 Jan 16  2018 mongodb_config.yml\ndrwxrwxr-x 2 usaxs usaxs 4.0K Feb 21 17:32 spec\n-rw-rw-r-- 1 usaxs usaxs  608 May 18 13:56 25-blackfly.py\n-rw-rw-r-- 1 usaxs usaxs 1.1K May 24 15:18 00-startup.py\n-rw-rw-r-- 1 usaxs usaxs 4.7K Jun  4 16:31 11-motors.py\n-rw-rw-r-- 1 usaxs usaxs  673 Jun 19 12:20 21-filters_shutters.py\n-rw-rw-r-- 1 usaxs usaxs 1.2K Jul 19 14:58 00-0-checks.py\n-rw-rw-r-- 1 usaxs usaxs   37 Jul 20 17:14 .loglogin\n-rw-rw-r-- 1 usaxs usaxs  816 Jul 25 10:07 60-metadata.py\n-rw-rw-r-- 1 usaxs usaxs  754 Jul 25 12:47 checklist.md\n-rw-rw-r-- 1 usaxs usaxs 5.8K Jul 27 12:38 32-usaxs_flyscan.py\n-rw-rw-r-- 1 usaxs usaxs 8.4K Jul 30 12:56 10-devices.py\n-rw-rw-r-- 1 usaxs usaxs 3.0K Jul 30 12:57 20-detectors.py\n-rw-rw-r-- 1 usaxs usaxs  19K Jul 30 12:59 22-amplifiers.py\n-rw-rw-r-- 1 usaxs usaxs 9.2K Jul 30 13:02 29-axis_tuning.py\n-rw-rw-r-- 1 usaxs usaxs 2.2K Jul 30 13:02 21-signals.py\n-rw-rw-r-- 1 usaxs usaxs  518 Jul 30 13:10 80-callbacks.py\n-rw-rw-r-- 1 usaxs usaxs  19K Jul 30 13:21 50-plans.py\n-rw-rw-r-- 1 usaxs usaxs 1.3K Jul 30 14:46 09-imports.py\n-rw-rw-r-- 1 usaxs usaxs  930 Jul 30 15:40 24-zz_APS_devices.py\ndrwxrwxr-x 3 usaxs usaxs 4.0K Jul 30 15:49 usaxs_support\n-rw-rw-r-- 1 usaxs usaxs  20K Jul 31 11:43 79-callbacks-overrrides.py\n-rw-rw-r-- 1 usaxs usaxs 1.2K Jul 31 18:38 25-simdetector.py\n-rw-rw-r-- 1 usaxs usaxs 1.6K Jul 31 18:38 25-pilatus.py\n-rw-rw-r-- 1 usaxs usaxs 1.3K Jul 31 18:38 25-alta.py\n-rw-rw-r-- 1 usaxs usaxs 6.9K Jul 31 18:38 24-detector_data_file_names.py\ndrwxrwxr-x 3 usaxs usaxs 4.0K Aug  2 17:05 notebooks\ndrwxrwxr-x 5 usaxs usaxs 4.0K Aug  8 12:18 .\n-rw------- 1 usaxs usaxs 848K Aug  8 12:18 core\ndrwxr-xr-x 7 usaxs usaxs 4.0K Aug  8 12:21 ..\n',
prjemian commented 6 years ago

email_notices.send("test"," message from bluesky") hangs

prjemian commented 6 years ago

this works:

In [4]: email_notices.add_addresses("jemian@anl.gov", "prjemian@gmail.com")

In [5]: email_notices.addresses
Out[5]: 
['ilavsky@aps.anl.gov',
 'kuzmenko@aps.anl.gov',
 'mfrith@anl.gov',
 'jemian@anl.gov',
 'prjemian@gmail.com']
prjemian commented 6 years ago

so far:

In [6]: unix_cmd("echo mail test_message -s from_bluesky jemian@anl.gov prjemian@gmail.com".split())
Out[6]: (b'mail test_message -s from_bluesky jemian@anl.gov prjemian@gmail.com\n', b'')
prjemian commented 6 years ago

this does not return:

In [7]: unix_cmd("mail test_message -s from_bluesky jemian@anl.gov prjemian@gmail.com".split())
prjemian commented 6 years ago

Aha! things have changed...

(base) usaxs@usaxscontrol .../07/30 $ mail test_message -s from_bluesky jemian@anl.gov prjemian@gmail.com
Subject: ^C
prjemian commented 6 years ago
(base) usaxs@usaxscontrol .../07/30 $ mail -h
mail: option requires an argument -- h
Usage: mail -eiIUdEFntBDNHRVv~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
prjemian commented 6 years ago

work this out offline

prjemian commented 5 years ago

Now using the mailx program. Use echo and a pipe to send the message now:

echo "another test" | mail  -s "from testing" jemian@anl.gov prjemian@gmail.com
prjemian commented 5 years ago

Can't use pipes in this context. Refactor with email package.