Convert from STRS Email to an HTML file to Forward via Email
Usage
The Email2Request script is used to create a file formatted for forwarding. The input data is obtained from an eMail created by a web page using FormMail when the submit button is clicked. The script provides a convenient and consistent way of forwarding the request to the appropriate contact.
Setup
- Install Python. See Python download site. The script was tested against Python 2.7 and Python 3.2. Since there were residual errors when handling special characters in Python 2.7, it is recommended that the user install and use Python 3.2 or above.
- Create/find a working directory to store scripts and execution results for upload and download.
- Save the Email2Request.python.txt script (from eRoom) to that working directory.
- Save the FormMail email, as UTF-8 (or Unicode) text, with the name identified on the line containing “Suggest_File_Name:”, into the working directory identified.
Convert
- Run the Email2Request procedure/script as described below. The usage is:
usage: Email2Request.python.txt [-h] [-f REQUESTFILE] [-s SUBDIRECTORY] fileIn Convert a form from email saved as text into an HTML web page file for forwarding. positional arguments: fileIn Path to file to be analyzed. optional arguments: -h, --help show this help message and exit -f [REQUESTFILE], --file [REQUESTFILE] Output file name. Add ".html", if ".html" is not there. STRS.Request.date.html is used if no file name is specified. -s SUBDIRECTORY, --subdirectory SUBDIRECTORY Subdirectory to output web page file.
- In a PC command window, execute python script Email2Request.python.txt with input being the file just saved and the output being a new file; for example:
cd C:<\SoftwareDefinedRadio\STRS Repository
C:\python27\python Email2Request.python.txt “strs-repository-manager STRS Application Repository Request.txt”
or
C:\python32\python Email2Request.python.txt “strs-repository-manager STRS Application Repository Request.txt” - In a Linux command window, execute python script Email2Request.python.txt
with input being the file just saved and the output being a new file; for example:
cd $HOME/strs/20120207
python Email2Request.python.txt “strs-repository-manager STRS Application Repository Request.txt”
or
python27 Email2Request.python.txt “strs-repository-manager STRS Application Repository Request.txt”
or
python32 Email2Request.python.txt “strs-repository-manager STRS Application Repository Request.txt” - Note that the Email2Request procedure/script has only been tested using “Python 2.7.3” and “Python 3.2.3”. If you have an older version, it may not work. To determine which version of python you are using, type python (or equivalent) on a command line. It will return the version in an interactive mode. To exit, type “exit()” or “quit()” or Ctrl-Z plus Return.
- Note that if you install python, python must be started so that it can find the corresponding python-related files. On Linux, for example, the PATH variable needed to be changed and the easiest way to do this was to create a Bourne shell script. For example, to execute python in $HOME/python-2.7.3, I created $HOME/bin/python27 (where $HOME/bin is already in the PATH variable) containing:
#!/bin/sh # python27 ... PATH=$HOME/Python-2.7.3:$PATH python $*
Then I made $HOME/bin/python27 executable (chmod +x $HOME/bin/python27) and executed the following, after reinitializing the command window shell:
python27 Email2Request.python.txt -f output.html input.txt
which worked fine.
- In a PC command window, execute python script Email2Request.python.txt with input being the file just saved and the output being a new file; for example:
- Check the resulting HTML web page file in a browser to verify that it matches the original eRoom database.
- Send the resulting HTML web page file to the appropriate management contact.
- Look up the management contact information in the STRS Application Manager Restricted Metadata.
- Create an email to the appropriate management contact with a copy to grc-dl-strs-repository-manager@mail.nasa.gov.
- Encrypt the HTML web page.
- Attach the encrypted HTML web page.
- Send the email.
- Send a separate email with decription information.
I>path