Create a web page of Source Lines of Code (SLOC) to be used to support Constructive Cost Model (COCOMO) computation
Usage
The getSLOC Python script is used to count source lines of code (omitting comments) in a directory tree and create a web page containing the individual SLOC as well as the totals. This is used two ways: as an item of metadata and as input to COCOMO computation. As an item of metadata, you can merely email the resulting web page file to the STRS repository manager at grc-dl-strs-repository-manager@mail.nasa.gov.
The are many estimated software development time and level of effort web page calculators available on the internet; however, the estimated software development time and level of effort web page calculator adapted for use with STRS may be executed and the results copy/pasted into an email sent to the STRS repository manager. There are many alternatives to this process; for example, the SLOCcount program. The SLOCcount program is available for download.
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. This working directory must be outside the directory tree to be analyzed.
- Save the getSLOC.python.txt script into that working directory.
Create Web Page of Directory Tree Contents
- Find base of directory tree.
- In a command window, execute the python script getSLOC.python.txt with the input directory being the base of the directory tree and the output being the new HTML file.
usage: python getSLOC.python.txt [-h] directory optional arguments: -h, --help Show this help message and exit. positional arguments: directory Path to files to be analyzed.
- In a PC command window, the following was executed:
cd C:path\SoftwareDefinedRadio\STRS Repository C:\python27\python getSLOC.python.txt . or C:\python32\python getSLOC.python.txt . ... ************************************************************************ ** Created web file: SLOC.20130916090732.html, containing 121 items. *** ************************************************************************
Note that if there are any spaces in the command line directory name, a single set of quotes is sufficient to make python get the command line arguments as a single string.
- Escaping the spaces in the command line did not work.
- Substituting for each space in the command line did not work.
- On Linux, using mixed quotes around a directory name with spaces works. One set of quotes is consumed by the Linux Bourne shell and the remaining set is recognized by python, where the quotes disappear when using argparse and it can’t find the end of the directory name with spaces. However, only the inner set of quotes disappear which allowed a work-around where I parsed the command line and put the pieces back together until the quotes matched.
- Display the HTML web file. Use the SLOC to perform COCOMO time and level of effort computation.
- Copy and paste the results into an email and send to the STRS repository manager. See next section for more information.
Encrypt
The following are some suggested methods to send encrypted metadata.
- Send the HTML file via LFT
- Attach the HTML file to an email, encrypt the email, and send it
- Encrypt the HTML file and email the encrypted file as an attachment.
- Highlight the results using select all, copy, and paste into your email program that can encrypt the email.
- Highlight the results using select all, copy, paste into a text editor or word processor, and save the file as text. Send via LFT or encrypt the file and email the encrypted file as an attachment.
- In Firefox or Internet Explorer, in the File menu, click on Save As or Save Page As and save as a text file. Send via LFT or encrypt the file and email the encrypted file as an attachment.
Neither PKI Entrust nor NOMAD Large File Transfer (LFT) can encrypt to a mailing list. External users can only use LFT to send to internal NASA users.
- If using PKI Entrust, click on this substitute mailing link instead of using the STRS repository manager’s mailing list. Do not send unencryption credentials in the same email.
- If you are an internal user using LFT, send metadata to Tina.G.Grzincic@nasa.gov and Janette.C.Briones@nasa.gov instead of using the STRS repository manager’s mailing list.
- If you are a user external to NASA, send an email to the STRS repository manager requesting access to NOMAD Large File Transfer (LFT) website. Once approved, you will receive an invitation email. Click on the link in the invitation email to access the Large File Transfer website and register for an account. Further instructions are located on the LFT website.
The NOMAD Large File Transfer service is now FIPS 140-2 certified for Data-in-Transit (DIT) and Data-at-Rest (DAR). This satisfies the NASA policy requirement to encrypt sensitive but unclassified (SBU) information while in transit – therefore you do not need to encrypt a file before sending it through LFT.