Changeset 965

Show
Ignore:
Timestamp:
02/22/12 16:41:28 (3 months ago)
Author:
frederick
Message:

Split some of the settings into separate input and output configuration files and updated the source tree accordingly to reflect the new locations of the relocated settings.

Location:
trunk/synthesis/src
Files:
1 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/synthesis/src/conf/outputConfiguration.py

    r962 r965  
    11'''see ./docs/output_configurations.readme for information on setting these configurations''' 
    22#!/usr/bin/env python 
    3  
     3import os 
    44import settings 
    55 
    6 # Adding a vendor.  Simply append a record by following the format below. 
     6PROCESSEDFILES_PATH = os.path.join(settings.BASE_PATH, "processed_files") 
     7if not os.path.exists(PROCESSEDFILES_PATH): 
     8    os.mkdir(PROCESSEDFILES_PATH) 
     9 
     10# Adding a vendor.  Simply append a record by following the sample format below. 
    711 
    812Configuration = \ 
    913{ 
     14    # Sample Format 
     15    'Source ID (e.g. 001)': 
     16        { 
     17            'vendor': '', 
     18            'outputFormat': '', # Possible values:  
     19            'destinationURL': '', 
     20            'transportConfiguration': 'save', # Possible values: "save" (to directory), "soap", "rest", "ftps", "sftp" 
     21            'encryption': 'none', # Possible values: "none", "3des", "openpgp" 
     22            # when transportConfiguration is set to "save", set destination to the absolute path of the save directory 
     23            'destination': settings.BASE_PATH + '/output_files', 
     24            # frequency controls how often nodebuilder runs and can be set to "asap" (later on maybe "daily", "weekly", monthly") 
     25            'frequency': 'asap' 
     26        }, 
    1027    'occtest':#For HUD files in test_files folder 
    1128        { 
     
    1431            'destinationURL': 'https://pix.penguix.net:8023/docs', 
    1532            #'destinationURL': 'http://127.0.0.1:5000/docs', 
    16             # transport type can be set to "save" (to directory), "soap", "rest", "ftps", "sftp" 
    1733            'transportConfiguration': 'save', 
    18             # encryption type can be set to "none", "openpgp", "3des" 
    1934            'encryption': '3des', 
    20             # when transportConfiguration is set to "save", set destination to the absolute path of the save directory 
    2135            'destination': settings.BASE_PATH + '/occ_output_files', 
    22             # frequency controls how often nodebuilder runs and can be set to "asap" (later on maybe "daily", "weekly", monthly") 
    2336            'frequency': 'asap' 
    2437        }, 
     
    2841            'outputFormat': 'pseudo', 
    2942            'destinationURL': 'https://pix.penguix.net:8024/docs', 
    30             #'destinationURL': 'http://127.0.0.1:5001/docs', 
    31             # transport type can be set to "save" (to directory), "soap", "rest", "ftps", "sftp" 
    3243            'transportConfiguration': 'save', 
    33             # encryption type can be set to "none", "openpgp", "3des" 
    3444            'encryption': 'none', 
    35             # when transportConfiguration is set to "save", set destination to the absolute path of the save directory 
    3645            'destination': settings.BASE_PATH + '/tbc_output_files', 
    37             # frequency controls how often nodebuilder runs and can be set to "asap" (later on maybe "daily", "weekly", monthly") 
    3846            'frequency': 'asap' 
    3947        }, 
     
    4250            'vendor': 'Orange County Corrections', 
    4351            'outputFormat': 'svcpoint5', 
    44             #'destinationURL': 'https://pix.penguix.net:8024/docs', 
    4552            'destinationURL': 'http://fby.homeip.net:8092/docs', 
    46             #'destinationURL': 'http://127.0.0.1:5000/docs', 
    47             # transport type can be set to "save" (to directory), "soap", "rest", "ftps", "sftp" 
    4853            'transportConfiguration': 'save', 
    49             # encryption type can be set to "none", "openpgp", "3des" 
    5054            'encryption': 'none', 
    51             # when transportConfiguration is set to "save", set destination to the absolute path of the save directory 
    5255            'destination': settings.BASE_PATH + '/output_files', 
    53             # frequency controls how often nodebuilder runs and can be set to "asap" (later on maybe "daily", "weekly", monthly") 
    5456            'frequency': 'asap' 
    5557        }, 
     
    130132        }, 
    131133} 
    132  
  • trunk/synthesis/src/conf/settings.py

    r962 r965  
    1717GUI = False   
    1818# DB settings: 
    19 DB_DATABASE = "your_database_name_here(synthesis perhaps)" 
    20 DB_USER = "your_database_user_name_here" 
    21 DB_PASSWD = "your_password_here" 
     19DB_DATABASE = "synthesis" 
     20DB_USER = "synthesis" 
     21DB_PASSWD = "synthesis" 
    2222DB_PORT = 5432 
    2323DB_HOST = "localhost" 
     
    2929#SOURCE_PATH = 'synthesis' 
    3030#BASE_PATH = os.path.join(os.getcwd(), SOURCE_PATH) 
    31 BASE_PATH = "/home/username/myrestservice/synthesis/synthesis" 
     31BASE_PATH = "~/myrestservice/synthesis/synthesis" 
    3232print "BASE_PATH is: ", BASE_PATH 
    3333#import pydevd; pydevd.settrace() 
    3434#ABS_SOURCE_PATH = os.path.abspath(os.getcwd() + SOURCE_PATH) 
    3535PATH_TO_GPG = '/usr/bin/gpg' 
    36 PGPHOMEDIR = '' 
     36PGPHOMEDIR = '~/.gnupg' 
    3737PASSPHRASE = '' 
    3838FINGERPRINT = '' 
     39DES3_KEY = '' 
     40 
    3941JFCS_SOURCE_ID = 734 
    4042JFCS_AGENCY_ID = 711 
     
    4648NUMBER_OF_PROCESSES = 1  
    4749 
    48 # <rim:Classification /> properties 
    49 AUTHOR_PERSON = "John Doe" 
    50 AUTHOR_INSTITUTION = "ACME" 
    51 AUTHOR_ROLE = "Wise Man" 
    52 AUTHOR_SPECIALTY = "Mediation" 
    53 NODE_REPRESENTATION = "Not Available" 
    54 CODING_SCHEME = "LOINC" 
    55 LOCALIZED_STRING = "Not Available" 
     50# <rim:Classification /> properties (used by the soaptransport) 
     51AUTHOR_PERSON = "" 
     52AUTHOR_INSTITUTION = "" 
     53AUTHOR_ROLE = "" 
     54AUTHOR_SPECIALTY = "" 
     55NODE_REPRESENTATION = "" 
     56CODING_SCHEME = "" 
     57LOCALIZED_STRING = "" 
    5658 
    57 # Input files Processing path 
    58 # New 'Customers' input file path must be put into this 'list'.  Add it to the list mechanism.   
    59 INPUTFILES_PATH = [ 
    60             BASE_PATH + "/input_files" 
    61             , 
    62             ] 
    63 WEB_SERVICE_INPUTFILES_PATH = [ 
    64             BASE_PATH + "/ws_input_files" 
    65             , 
    66             ] 
    6759# subfolder  
    6860#XSD_PATH = SOURCE_PATH + "/" + "xsd" 
     
    7365#    os.mkdir(OUTPUTFILES_PATH) 
    7466     
    75 USEDFILES_PATH = os.path.join(BASE_PATH, "used_files") 
    76 if not os.path.exists(USEDFILES_PATH): 
    77     os.mkdir(USEDFILES_PATH) 
    78      
    79 FAILEDFILES_PATH = os.path.join(BASE_PATH, "failed_files") 
    80 if not os.path.exists(FAILEDFILES_PATH): 
    81     os.mkdir(FAILEDFILES_PATH) 
    82  
    83 PROCESSEDFILES_PATH = os.path.join(BASE_PATH, "processed_files") 
    84 if not os.path.exists(PROCESSEDFILES_PATH): 
    85     os.mkdir(PROCESSEDFILES_PATH)     
    86  
    8767#logging settings file location setup 
    8868logging_level = 0 
     
    9878if not os.path.exists(LOGS): 
    9979    os.mkdir(LOGS) 
    100  
    101 PROCESSED_PATH = "" 
    10280 
    10381SCHEMA_DOCS = { 
     
    127105SMTPSENDERPWD = 'mysecret' 
    128106 
    129 # SMTP Mail recipients is a dictionary that must be defined for each source of input files 
    130 SMTPRECIPIENTS = {     
    131         "~/myrestservice/synthesis/synthesis/input_files": 
    132         { 
    133         'VENDOR_NAME': 'SomeVendor', 
    134         'SMTPTOADDRESS': ['someone@somedomain.com',], 
    135         'SMTPTOADDRESSCC': [], 
    136         'SMTPTOADDRESSBCC': [], 
    137         'FINGERPRINT':'', 
    138         'USES_ENCRYPTION':False 
    139         } 
    140     ,"~/myrestservice/synthesis/synthesis/input_files2": 
    141         { 
    142         'VENDOR_NAME': 'SomeVendor2', 
    143         'SMTPTOADDRESS': ['admin@superhost.com',], 
    144         'SMTPTOADDRESSCC': [], 
    145         'SMTPTOADDRESSBCC': [], 
    146         'FINGERPRINT':'', 
    147         'USES_ENCRYPTION':False 
    148         } 
    149     ,"~/myrestservice/synthesis/synthesis/input_files3": 
    150         { 
    151         'VENDOR_NAME': '', 
    152         'SMTPTOADDRESS': ['sammy.davis@jr.com',], 
    153         'SMTPTOADDRESSCC': [], 
    154         'SMTPTOADDRESSBCC': [], 
    155         'FINGERPRINT':'', 
    156         'USES_ENCRYPTION':False 
    157         } 
    158 # output processing 
    159     ,"~/myrestservice/synthesis/synthesis/output_files": 
    160         { 
    161         'VENDOR_NAME': '', 
    162         'SMTPTOADDRESS': ['user@host.com',], 
    163         'SMTPTOADDRESSCC': [], 
    164         'SMTPTOADDRESSBCC': [], 
    165         'FINGERPRINT':'', 
    166         'USES_ENCRYPTION':False 
    167         } 
    168     ,"~/myrestservice/synthesis/synthesis/output_files2": 
    169         { 
    170         'VENDOR_NAME': '', 
    171         'SMTPTOADDRESS': ['admin@somehost.com',], 
    172         'SMTPTOADDRESSCC': [], 
    173         'SMTPTOADDRESSBCC': [], 
    174         'FINGERPRINT':'', 
    175         'USES_ENCRYPTION':False 
    176         } 
    177     } 
    178107try: 
    179108    from local_settings import * 
    180109except ImportError: 
    181110    pass 
    182  
    183  
  • trunk/synthesis/src/controllers/docs.py

    r958 r965  
    1 #use_encryption = True 
    2 use_encryption = False 
    3  
     1from conf import settings 
     2from conf import inputConfiguration 
    43import os 
    54import logging 
     
    1110import urllib 
    1211from webob import Request 
    13 if use_encryption: 
     12if inputConfiguration.USE_ENCRYPTION: 
    1413    from Encryption import * 
    15 from conf import settings 
    1614from selector import Selector 
    1715import base64 
     
    5957        file_suffix_enc = '_encrypted.xml' 
    6058        file_suffix_unenc = '_unencrypted.xml' 
    61         if use_encryption: 
     59        if inputConfiguration.USE_ENCRYPTION: 
    6260            print "using encryption" 
    6361            file_name = file_prefix + file_suffix_enc 
    64         elif not use_encryption: 
     62        elif not inputConfiguration.USE_ENCRYPTION: 
    6563            print "not using encryption" 
    6664            file_name = file_prefix + file_suffix_unenc 
     
    6866            print "not sure if using encrypted file or not" 
    6967         
    70         if not os.path.exists(settings.WEB_SERVICE_INPUTFILES_PATH[0]): 
    71                 os.mkdir(settings.WEB_SERVICE_INPUTFILES_PATH[0]) 
    72         file_full_path = os.path.join(settings.WEB_SERVICE_INPUTFILES_PATH[0], file_name) 
     68        if not os.path.exists(inputConfiguration.WEB_SERVICE_INPUTFILES_PATH[0]): 
     69                os.mkdir(inputConfiguration.WEB_SERVICE_INPUTFILES_PATH[0]) 
     70        file_full_path = os.path.join(inputConfiguration.WEB_SERVICE_INPUTFILES_PATH[0], file_name) 
    7371        print 'file_full_path: ', file_full_path 
    7472         
    7573        #open file  
    76         if use_encryption: 
     74        if inputConfiguration.USE_ENCRYPTION: 
    7775            try: 
    7876                print "trying to open encrypted file" 
     
    8078            except: 
    8179                print "Error opening encrypted instance file for writing" 
    82         if not use_encryption: 
     80        if not inputConfiguration.USE_ENCRYPTION: 
    8381            try: 
    8482                print "trying to open unencrypted file" 
     
    8886                 
    8987        #write to file 
    90         if use_encryption: 
     88        if inputConfiguration.USE_ENCRYPTION: 
    9189            print 'writing', file_name, 'to', server_root, 'for decryption' 
    9290            print 'encrypted_file is', encrypted_file 
     
    9492            encrypted_file.close() 
    9593             
    96         if not use_encryption: 
     94        if not inputConfiguration.USE_ENCRYPTION: 
    9795            print 'writing', file_name, 'to', server_root, 'server root for parsing' 
    9896            print 'unencrypted_file is', unencrypted_file 
     
    109107        #assume file is encrypted, since it can be difficult to tell if it is.  We could look for XML structures, but how do you easily tell bad/invalid  XML apart from encrypted?  If not encrypted, that's a problem. 
    110108        #decrypt file 
    111         if use_encryption: 
     109        if inputConfiguration.USE_ENCRYPTION: 
    112110            try: 
    113111                encrypted_file = open(file_full_path, 'r')  
     
    148146                file_suffix_unenc = '_decrypted.xml' 
    149147                file_name = file_prefix + file_suffix_unenc 
    150                 file_full_path =  settings.INPUTFILES_PATH[0] + '/' + file_name 
     148                file_full_path =  inputConfiguration.INPUTFILES_PATH[0] + '/' + file_name 
    151149                try: 
    152150                    decrypted_file = open(file_full_path, 'w') 
     
    167165         
    168166        #read in candidate XML file 
    169 #        if use_encryption: 
     167#        if inputConfiguration.USE_ENCRYPTION: 
    170168#            try: 
    171169#                unencrypted_file = open(file_full_path, 'r')  
     
    173171#                print "couldn't open decrypted file for reading" 
    174172#             
    175 #        if not use_encryption: 
     173#        if inputConfiguration.USE_ENCRYPTION: 
    176174#            try: 
    177175#                unencrypted_file = open(file_full_path, 'r')  
     
    193191            print "moving valid file ", file_name, "over to input_files for shredding" 
    194192            import fileutils 
    195             fileutils.moveFile(file_full_path, settings.INPUTFILES_PATH[0]) 
     193            fileutils.moveFile(file_full_path, inputConfiguration.INPUTFILES_PATH[0]) 
    196194            return message 
    197195        except: 
  • trunk/synthesis/src/emailprocessor.py

    r809 r965  
    11from smtplibrary import smtpInterface 
    22from conf import settings 
     3from conf import inputConfiguration 
    34import os 
    45from security import Security 
     
    1516        if docName <> '': 
    1617            folderName = os.path.split(docName)[0] 
    17             self.mailSystem.setRecipients(settings.SMTPRECIPIENTS[folderName]) 
     18            self.mailSystem.setRecipients(inputConfiguration.SMTPRECIPIENTS[folderName]) 
    1819            self.docName = docName 
    1920        else: 
     
    2223                try: 
    2324                    folderName = os.path.split(docs[0])[0] 
    24                     self.mailSystem.setRecipients(settings.SMTPRECIPIENTS[folderName]) 
     25                    self.mailSystem.setRecipients(inputConfiguration.SMTPRECIPIENTS[folderName]) 
    2526                except KeyError: 
    2627                    raise 
  • trunk/synthesis/src/filerouter.py

    r809 r965  
    11import fileutils 
     2from conf import inputConfiguration 
    23from conf import settings 
    34 
     
    910    def moveUsed(self, file_name): 
    1011        if settings.DEBUG: 
    11             print "moving ", file_name, "to", settings.USEDFILES_PATH 
    12         fileutils.moveFile(file_name, settings.USEDFILES_PATH) 
     12            print "moving ", file_name, "to", inputConfiguration.USEDFILES_PATH 
     13        fileutils.moveFile(file_name, inputConfiguration.USEDFILES_PATH) 
    1314 
    1415    def moveFailed(self, fileName): 
    15         fileutils.moveFile(fileName, settings.FAILEDFILES_PATH) 
     16        fileutils.moveFile(fileName, inputConfiguration.FAILEDFILES_PATH) 
    1617 
    1718 
  • trunk/synthesis/src/resttransport.py

    r962 r965  
    33HAS_CONF = True 
    44HAS_ENCRYPTION = True 
    5 #POST_URL = "http://127.0.0.1:5000/docs" 
    6 OCC_POST_URL = "https://pix.penguix.net:8023/occdocs" 
    7 TBC_POST_URL = "https://pix.penguix.net:8023/tbcdocs" 
     5SENT_TO_LOCAL = True 
     6 
     7if SENT_TO_LOCAL: 
     8# LOCALHOST URLS 
     9    OCC_POST_URL = "http://127.0.0.1:5000/docs" 
     10    TBC_POST_URL = "http://127.0.0.1:5000/docs" 
     11else: 
     12# TEST SERVER URLS 
     13    OCC_POST_URL = "https://pix.penguix.net:8023/docs" 
     14    TBC_POST_URL = "https://pix.penguix.net:8024/docs" 
     15 
    816import base64 
    917try: 
     
    7280    <ext:Source> 
    7381        <ext:SourceID> 
    74                 <hmis:IDStr>occtest</hmis:IDStr> 
     82                <hmis:IDStr>003</hmis:IDStr> 
    7583        </ext:SourceID> 
    7684        <ext:SoftwareVendor>OCC</ext:SoftwareVendor> 
     
    147155     
    148156    # test results 
    149     #print "Result of OCC test (unencrypted): ", rest.post("occtest", occ_xml) 
    150      
    151157    if HAS_ENCRYPTION: 
    152158        des3 = DES3() 
     
    154160        #print encrypted_data 
    155161        print "Result of OCC test (encrypted): ", rest.post("occtest", encrypted_data, use_base64=True) 
     162    else: 
     163        print "Result of OCC test (unencrypted): ", rest.post("occtest", occ_xml, use_base64=False) 
    156164 
    157165def tbctest(): 
     
    164172    xmlns:hmis="http://www.hmis.info/schema/3_0/HUD_HMIS.xsd"  
    165173    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    166     xsi:schemaLocation="http://xsd.alexandriaconsulting.com/repos/trunk/HUD_HMIS_XML/TBC_Extend_HUD_HMIS.xsd http://xsd.alexandriaconsulting.com/repos/trunk/HUD_HMIS_XML/TBC_Extend_HUD_HMIS.xsd" 
     174    xsi:schemaLocation="http://xsd.alexandriaconsulting.com/repos/trunk/HUD_HMIS_XML/TBC_Extend_HUD_HMIS.xsd http://xsd.alexandriaconsulting.com/repos/trunk/HUD_HMIS_XML/TBC_Extend_HUD_HMIS.xsd"  
    167175    ext:version="3.0"> 
    168176    <ext:Source> 
    169177        <ext:SourceID > 
    170                 <hmis:IDStr>tbctest</hmis:IDStr> 
     178                <hmis:IDStr>003</hmis:IDStr> 
    171179        </ext:SourceID> 
    172         <ext:SoftwareVendor>TBC</ext:SoftwareVendor> 
     180        <ext:SoftwareVendor>Vendor Name Here</ext:SoftwareVendor> 
    173181        <ext:SoftwareVersion>7.1</ext:SoftwareVersion> 
    174182        <ext:SourceName>Source Name Here</ext:SourceName> 
     
    176184            <ext:ExportID > 
    177185                <!-- Since this is the first export, it's "1".  The second will be "2". --> 
    178                     <hmis:IDNum>11</hmis:IDNum> 
     186                    <hmis:IDNum>1010111</hmis:IDNum> 
    179187            </ext:ExportID> 
    180188            <ext:ExportDate>2011-09-23T18:51:58</ext:ExportDate> 
     
    186194            <ext:Person> 
    187195                <ext:PersonID> 
    188                     <hmis:IDNum>090888539</hmis:IDNum> 
     196                    <hmis:IDNum>2090888539</hmis:IDNum> 
    189197                </ext:PersonID> 
    190198                <ext:DateOfBirth> 
     
    297305     
    298306    # test results 
    299     #print "Result of TBC test (unencrypted): ", rest.post("tbctest", tbc_xml) 
    300  
    301307    if HAS_ENCRYPTION: 
    302308        gpg = GPG() 
     
    304310        #print encrypted_data 
    305311        print "Result of TBC test (encrypted): ", rest.post("tbctest", encrypted_data, use_base64=True) 
     312    else: 
     313        print "Result of TBC test (unencrypted): ", rest.post("tbctest", tbc_xml, use_base64=False) 
    306314 
    307315if __name__ == "__main__": 
  • trunk/synthesis/src/selector.py

    r957 r965  
    1616import Queue 
    1717from conf import settings 
     18from conf import inputConfiguration 
    1819from synthesis.emailprocessor import XMLProcessorNotifier 
    1920from filerouter import Router 
     
    3738 
    3839        #change this so that it gets the watch_dir from the .ini file 
    39         dir_to_watch = settings.INPUTFILES_PATH  
     40        dir_to_watch = inputConfiguration.INPUTFILES_PATH  
    4041        self.queue = Queue.Queue(0) 
    4142        self.file_input_watcher = FileInputWatcher(dir_to_watch, self.queue) 
     
    7980        if os.path.isdir(folderName):  
    8081            try: 
    81                 self.ProcessingOptions = settings.SMTPRECIPIENTS[folderName] 
     82                self.ProcessingOptions = inputConfiguration.SMTPRECIPIENTS[folderName] 
    8283            except: 
    8384                raise 
     
    162163        listOfFiles = list() 
    163164        # Loop over list of file locations [list] 
    164         for folder in settings.INPUTFILES_PATH: 
     165        for folder in inputConfiguration.INPUTFILES_PATH: 
    165166            listOfFiles.extend(fileutils.grabFiles(path.join(folder,'*'))) 
    166167            if settings.DEBUG: 
  • trunk/synthesis/src/soaptransport.py

    r937 r965  
    77import urlparse 
    88import uuid 
     9import base64 
    910 
    1011class SoapEnv(): 
     
    134135    def send_soap_envelope(self, ccd_data, test=False): 
    135136        # construct the message and header 
    136         self._transport_properties["CCD"] = ccd_data 
     137        self._transport_properties["CCD"] = base64.b64encode(ccd_data) 
    137138        soap_env = self._ENVELOPE_TEMPLATE % self._transport_properties 
    138139        headers = { 
     
    152153            import pprint as pp 
    153154            pp.pprint(headers) 
    154             print soap_env 
     155            #print soap_env 
     156            fo = open('soap_envelope.txt', 'w') 
     157            fo.write(soap_env) 
     158            fo.flush() 
     159            fo.close() 
    155160            return (True, "True") 
    156161 
     
    337342 
    338343    soap = SoapEnv('iH9HiPbW40JbS5m_') 
    339     soap.send_soap_envelope(ccd_data) 
     344    soap.send_soap_envelope(ccd_data, True)