National Aeronautics and Space Administration

Glenn Research Center

getSLOC

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 strs-repository-manager@lists.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

  1. 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.
  2. 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.
  3. Save the getSLOC.python.txt script into that working directory.

Create Web Page of Directory Tree Contents

  1. Find base of directory tree.
  2. 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.
  3. In a PC command window, the following was executed:
    cd C:\Users\lhandler\Documents\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.

    • On Windows using one set of quotes around a directory name containing spaces, the quotes disappear but the name with spaces is parsed properly.
    • On Windows using mixed quotes around a directory name containing spaces (i.e. using both single and double quotes, for example, “‘a b c'”), any double quotes disappear but the directory name is parsed properly.
  4. In a Linux command window, the following was executed:
    cd $HOME/strs/20120207
      python27 getSLOC.python.txt STRS_Architecture/WFCCN
    or
      python32 getSLOC.python.txt STRS_Architecture/WFCCN
    ...
    ************************************************************************
    ** 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 are not 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.
  5. Display the HTML web file. Use the SLOC to perform COCOMO time and level of effort computation.
  6. 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.