Changeset 965
- Timestamp:
- 02/22/12 16:41:28 (3 months ago)
- Location:
- trunk/synthesis/src
- Files:
-
- 1 added
- 8 modified
-
conf/inputConfiguration.py (added)
-
conf/outputConfiguration.py (modified) (5 diffs)
-
conf/settings.py (modified) (6 diffs)
-
controllers/docs.py (modified) (12 diffs)
-
emailprocessor.py (modified) (3 diffs)
-
filerouter.py (modified) (2 diffs)
-
resttransport.py (modified) (9 diffs)
-
selector.py (modified) (4 diffs)
-
soaptransport.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/synthesis/src/conf/outputConfiguration.py
r962 r965 1 1 '''see ./docs/output_configurations.readme for information on setting these configurations''' 2 2 #!/usr/bin/env python 3 3 import os 4 4 import settings 5 5 6 # Adding a vendor. Simply append a record by following the format below. 6 PROCESSEDFILES_PATH = os.path.join(settings.BASE_PATH, "processed_files") 7 if 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. 7 11 8 12 Configuration = \ 9 13 { 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 }, 10 27 'occtest':#For HUD files in test_files folder 11 28 { … … 14 31 'destinationURL': 'https://pix.penguix.net:8023/docs', 15 32 #'destinationURL': 'http://127.0.0.1:5000/docs', 16 # transport type can be set to "save" (to directory), "soap", "rest", "ftps", "sftp"17 33 'transportConfiguration': 'save', 18 # encryption type can be set to "none", "openpgp", "3des"19 34 'encryption': '3des', 20 # when transportConfiguration is set to "save", set destination to the absolute path of the save directory21 35 '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")23 36 'frequency': 'asap' 24 37 }, … … 28 41 'outputFormat': 'pseudo', 29 42 '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"32 43 'transportConfiguration': 'save', 33 # encryption type can be set to "none", "openpgp", "3des"34 44 'encryption': 'none', 35 # when transportConfiguration is set to "save", set destination to the absolute path of the save directory36 45 '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")38 46 'frequency': 'asap' 39 47 }, … … 42 50 'vendor': 'Orange County Corrections', 43 51 'outputFormat': 'svcpoint5', 44 #'destinationURL': 'https://pix.penguix.net:8024/docs',45 52 '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"48 53 'transportConfiguration': 'save', 49 # encryption type can be set to "none", "openpgp", "3des"50 54 'encryption': 'none', 51 # when transportConfiguration is set to "save", set destination to the absolute path of the save directory52 55 '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")54 56 'frequency': 'asap' 55 57 }, … … 130 132 }, 131 133 } 132 -
trunk/synthesis/src/conf/settings.py
r962 r965 17 17 GUI = False 18 18 # 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"19 DB_DATABASE = "synthesis" 20 DB_USER = "synthesis" 21 DB_PASSWD = "synthesis" 22 22 DB_PORT = 5432 23 23 DB_HOST = "localhost" … … 29 29 #SOURCE_PATH = 'synthesis' 30 30 #BASE_PATH = os.path.join(os.getcwd(), SOURCE_PATH) 31 BASE_PATH = " /home/username/myrestservice/synthesis/synthesis"31 BASE_PATH = "~/myrestservice/synthesis/synthesis" 32 32 print "BASE_PATH is: ", BASE_PATH 33 33 #import pydevd; pydevd.settrace() 34 34 #ABS_SOURCE_PATH = os.path.abspath(os.getcwd() + SOURCE_PATH) 35 35 PATH_TO_GPG = '/usr/bin/gpg' 36 PGPHOMEDIR = ' '36 PGPHOMEDIR = '~/.gnupg' 37 37 PASSPHRASE = '' 38 38 FINGERPRINT = '' 39 DES3_KEY = '' 40 39 41 JFCS_SOURCE_ID = 734 40 42 JFCS_AGENCY_ID = 711 … … 46 48 NUMBER_OF_PROCESSES = 1 47 49 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) 51 AUTHOR_PERSON = "" 52 AUTHOR_INSTITUTION = "" 53 AUTHOR_ROLE = "" 54 AUTHOR_SPECIALTY = "" 55 NODE_REPRESENTATION = "" 56 CODING_SCHEME = "" 57 LOCALIZED_STRING = "" 56 58 57 # Input files Processing path58 # 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 ]67 59 # subfolder 68 60 #XSD_PATH = SOURCE_PATH + "/" + "xsd" … … 73 65 # os.mkdir(OUTPUTFILES_PATH) 74 66 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 87 67 #logging settings file location setup 88 68 logging_level = 0 … … 98 78 if not os.path.exists(LOGS): 99 79 os.mkdir(LOGS) 100 101 PROCESSED_PATH = ""102 80 103 81 SCHEMA_DOCS = { … … 127 105 SMTPSENDERPWD = 'mysecret' 128 106 129 # SMTP Mail recipients is a dictionary that must be defined for each source of input files130 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':False139 }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':False148 }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':False157 }158 # output processing159 ,"~/myrestservice/synthesis/synthesis/output_files":160 {161 'VENDOR_NAME': '',162 'SMTPTOADDRESS': ['user@host.com',],163 'SMTPTOADDRESSCC': [],164 'SMTPTOADDRESSBCC': [],165 'FINGERPRINT':'',166 'USES_ENCRYPTION':False167 }168 ,"~/myrestservice/synthesis/synthesis/output_files2":169 {170 'VENDOR_NAME': '',171 'SMTPTOADDRESS': ['admin@somehost.com',],172 'SMTPTOADDRESSCC': [],173 'SMTPTOADDRESSBCC': [],174 'FINGERPRINT':'',175 'USES_ENCRYPTION':False176 }177 }178 107 try: 179 108 from local_settings import * 180 109 except ImportError: 181 110 pass 182 183 -
trunk/synthesis/src/controllers/docs.py
r958 r965 1 #use_encryption = True 2 use_encryption = False 3 1 from conf import settings 2 from conf import inputConfiguration 4 3 import os 5 4 import logging … … 11 10 import urllib 12 11 from webob import Request 13 if use_encryption:12 if inputConfiguration.USE_ENCRYPTION: 14 13 from Encryption import * 15 from conf import settings16 14 from selector import Selector 17 15 import base64 … … 59 57 file_suffix_enc = '_encrypted.xml' 60 58 file_suffix_unenc = '_unencrypted.xml' 61 if use_encryption:59 if inputConfiguration.USE_ENCRYPTION: 62 60 print "using encryption" 63 61 file_name = file_prefix + file_suffix_enc 64 elif not use_encryption:62 elif not inputConfiguration.USE_ENCRYPTION: 65 63 print "not using encryption" 66 64 file_name = file_prefix + file_suffix_unenc … … 68 66 print "not sure if using encrypted file or not" 69 67 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) 73 71 print 'file_full_path: ', file_full_path 74 72 75 73 #open file 76 if use_encryption:74 if inputConfiguration.USE_ENCRYPTION: 77 75 try: 78 76 print "trying to open encrypted file" … … 80 78 except: 81 79 print "Error opening encrypted instance file for writing" 82 if not use_encryption:80 if not inputConfiguration.USE_ENCRYPTION: 83 81 try: 84 82 print "trying to open unencrypted file" … … 88 86 89 87 #write to file 90 if use_encryption:88 if inputConfiguration.USE_ENCRYPTION: 91 89 print 'writing', file_name, 'to', server_root, 'for decryption' 92 90 print 'encrypted_file is', encrypted_file … … 94 92 encrypted_file.close() 95 93 96 if not use_encryption:94 if not inputConfiguration.USE_ENCRYPTION: 97 95 print 'writing', file_name, 'to', server_root, 'server root for parsing' 98 96 print 'unencrypted_file is', unencrypted_file … … 109 107 #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. 110 108 #decrypt file 111 if use_encryption:109 if inputConfiguration.USE_ENCRYPTION: 112 110 try: 113 111 encrypted_file = open(file_full_path, 'r') … … 148 146 file_suffix_unenc = '_decrypted.xml' 149 147 file_name = file_prefix + file_suffix_unenc 150 file_full_path = settings.INPUTFILES_PATH[0] + '/' + file_name148 file_full_path = inputConfiguration.INPUTFILES_PATH[0] + '/' + file_name 151 149 try: 152 150 decrypted_file = open(file_full_path, 'w') … … 167 165 168 166 #read in candidate XML file 169 # if use_encryption:167 # if inputConfiguration.USE_ENCRYPTION: 170 168 # try: 171 169 # unencrypted_file = open(file_full_path, 'r') … … 173 171 # print "couldn't open decrypted file for reading" 174 172 # 175 # if not use_encryption:173 # if inputConfiguration.USE_ENCRYPTION: 176 174 # try: 177 175 # unencrypted_file = open(file_full_path, 'r') … … 193 191 print "moving valid file ", file_name, "over to input_files for shredding" 194 192 import fileutils 195 fileutils.moveFile(file_full_path, settings.INPUTFILES_PATH[0])193 fileutils.moveFile(file_full_path, inputConfiguration.INPUTFILES_PATH[0]) 196 194 return message 197 195 except: -
trunk/synthesis/src/emailprocessor.py
r809 r965 1 1 from smtplibrary import smtpInterface 2 2 from conf import settings 3 from conf import inputConfiguration 3 4 import os 4 5 from security import Security … … 15 16 if docName <> '': 16 17 folderName = os.path.split(docName)[0] 17 self.mailSystem.setRecipients( settings.SMTPRECIPIENTS[folderName])18 self.mailSystem.setRecipients(inputConfiguration.SMTPRECIPIENTS[folderName]) 18 19 self.docName = docName 19 20 else: … … 22 23 try: 23 24 folderName = os.path.split(docs[0])[0] 24 self.mailSystem.setRecipients( settings.SMTPRECIPIENTS[folderName])25 self.mailSystem.setRecipients(inputConfiguration.SMTPRECIPIENTS[folderName]) 25 26 except KeyError: 26 27 raise -
trunk/synthesis/src/filerouter.py
r809 r965 1 1 import fileutils 2 from conf import inputConfiguration 2 3 from conf import settings 3 4 … … 9 10 def moveUsed(self, file_name): 10 11 if settings.DEBUG: 11 print "moving ", file_name, "to", settings.USEDFILES_PATH12 fileutils.moveFile(file_name, settings.USEDFILES_PATH)12 print "moving ", file_name, "to", inputConfiguration.USEDFILES_PATH 13 fileutils.moveFile(file_name, inputConfiguration.USEDFILES_PATH) 13 14 14 15 def moveFailed(self, fileName): 15 fileutils.moveFile(fileName, settings.FAILEDFILES_PATH)16 fileutils.moveFile(fileName, inputConfiguration.FAILEDFILES_PATH) 16 17 17 18 -
trunk/synthesis/src/resttransport.py
r962 r965 3 3 HAS_CONF = True 4 4 HAS_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" 5 SENT_TO_LOCAL = True 6 7 if 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" 11 else: 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 8 16 import base64 9 17 try: … … 72 80 <ext:Source> 73 81 <ext:SourceID> 74 <hmis:IDStr> occtest</hmis:IDStr>82 <hmis:IDStr>003</hmis:IDStr> 75 83 </ext:SourceID> 76 84 <ext:SoftwareVendor>OCC</ext:SoftwareVendor> … … 147 155 148 156 # test results 149 #print "Result of OCC test (unencrypted): ", rest.post("occtest", occ_xml)150 151 157 if HAS_ENCRYPTION: 152 158 des3 = DES3() … … 154 160 #print encrypted_data 155 161 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) 156 164 157 165 def tbctest(): … … 164 172 xmlns:hmis="http://www.hmis.info/schema/3_0/HUD_HMIS.xsd" 165 173 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" 167 175 ext:version="3.0"> 168 176 <ext:Source> 169 177 <ext:SourceID > 170 <hmis:IDStr> tbctest</hmis:IDStr>178 <hmis:IDStr>003</hmis:IDStr> 171 179 </ext:SourceID> 172 <ext:SoftwareVendor> TBC</ext:SoftwareVendor>180 <ext:SoftwareVendor>Vendor Name Here</ext:SoftwareVendor> 173 181 <ext:SoftwareVersion>7.1</ext:SoftwareVersion> 174 182 <ext:SourceName>Source Name Here</ext:SourceName> … … 176 184 <ext:ExportID > 177 185 <!-- Since this is the first export, it's "1". The second will be "2". --> 178 <hmis:IDNum>1 1</hmis:IDNum>186 <hmis:IDNum>1010111</hmis:IDNum> 179 187 </ext:ExportID> 180 188 <ext:ExportDate>2011-09-23T18:51:58</ext:ExportDate> … … 186 194 <ext:Person> 187 195 <ext:PersonID> 188 <hmis:IDNum> 090888539</hmis:IDNum>196 <hmis:IDNum>2090888539</hmis:IDNum> 189 197 </ext:PersonID> 190 198 <ext:DateOfBirth> … … 297 305 298 306 # test results 299 #print "Result of TBC test (unencrypted): ", rest.post("tbctest", tbc_xml)300 301 307 if HAS_ENCRYPTION: 302 308 gpg = GPG() … … 304 310 #print encrypted_data 305 311 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) 306 314 307 315 if __name__ == "__main__": -
trunk/synthesis/src/selector.py
r957 r965 16 16 import Queue 17 17 from conf import settings 18 from conf import inputConfiguration 18 19 from synthesis.emailprocessor import XMLProcessorNotifier 19 20 from filerouter import Router … … 37 38 38 39 #change this so that it gets the watch_dir from the .ini file 39 dir_to_watch = settings.INPUTFILES_PATH40 dir_to_watch = inputConfiguration.INPUTFILES_PATH 40 41 self.queue = Queue.Queue(0) 41 42 self.file_input_watcher = FileInputWatcher(dir_to_watch, self.queue) … … 79 80 if os.path.isdir(folderName): 80 81 try: 81 self.ProcessingOptions = settings.SMTPRECIPIENTS[folderName]82 self.ProcessingOptions = inputConfiguration.SMTPRECIPIENTS[folderName] 82 83 except: 83 84 raise … … 162 163 listOfFiles = list() 163 164 # Loop over list of file locations [list] 164 for folder in settings.INPUTFILES_PATH:165 for folder in inputConfiguration.INPUTFILES_PATH: 165 166 listOfFiles.extend(fileutils.grabFiles(path.join(folder,'*'))) 166 167 if settings.DEBUG: -
trunk/synthesis/src/soaptransport.py
r937 r965 7 7 import urlparse 8 8 import uuid 9 import base64 9 10 10 11 class SoapEnv(): … … 134 135 def send_soap_envelope(self, ccd_data, test=False): 135 136 # construct the message and header 136 self._transport_properties["CCD"] = ccd_data137 self._transport_properties["CCD"] = base64.b64encode(ccd_data) 137 138 soap_env = self._ENVELOPE_TEMPLATE % self._transport_properties 138 139 headers = { … … 152 153 import pprint as pp 153 154 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() 155 160 return (True, "True") 156 161 … … 337 342 338 343 soap = SoapEnv('iH9HiPbW40JbS5m_') 339 soap.send_soap_envelope(ccd_data )344 soap.send_soap_envelope(ccd_data, True)
