2121logger = logging .getLogger ('main' )
2222
2323class ServiceManager ():
24- def __init__ (self , debug = False ):
24+ def __init__ (self , debug = False , conn_dict = None ):
2525 self .debug = debug
2626 f = self ._get_file ('r' )
2727 self ._conn_dicts = []
2828 self .version = 0
2929 self ._connection_format = "%s+%s://%s:%s@%s/%s"
3030
3131 # Read all lines (connections) in the connection.cfg file
32- while True :
33- line = f .readline ()
34- if not line :
35- break
36- else :
37- line = line .split ()
38- #logger.debug(line)
39-
40- if len (line ) >= 5 :
41- line_dict = {}
42-
43- line_dict ['engine' ] = line [0 ]
44- line_dict ['user' ] = line [1 ]
45- line_dict ['password' ] = line [2 ]
46- line_dict ['address' ] = line [3 ]
47- line_dict ['db' ] = line [4 ]
48- self ._conn_dicts .append (line_dict )
32+ if conn_dict is None :
33+ while True :
34+ line = f .readline ()
35+ if not line :
36+ break
37+ else :
38+ line = line .split ()
39+ #logger.debug(line)
40+
41+ if len (line ) >= 5 :
42+ line_dict = {}
43+
44+ line_dict ['engine' ] = line [0 ]
45+ line_dict ['user' ] = line [1 ]
46+ line_dict ['password' ] = line [2 ]
47+ line_dict ['address' ] = line [3 ]
48+ line_dict ['db' ] = line [4 ]
49+ self ._conn_dicts .append (line_dict )
50+ else :
51+ self ._conn_dicts .append (conn_dict )
4952
5053 if len (self ._conn_dicts ) is not 0 :
5154 # The current connection defaults to the most recent (i.e. the last written to the file)
@@ -152,7 +155,7 @@ def get_cv_service(self):
152155 return CVService (conn_string , self .debug )
153156
154157 def get_edit_service (self , series_id , connection ):
155-
158+
156159 return EditService (series_id , connection = connection , debug = self .debug )
157160
158161 def get_record_service (self , script , series_id , connection ):
@@ -197,6 +200,10 @@ def _build_connection_string(self, conn_dict):
197200 # (conn_dict['address'], conn_dict['user'], conn_dict['password'],conn_dict['db'],
198201 # ))
199202 conn_string = 'mssql+pyodbc:///?odbc_connect={}' .format (quoted )
203+
204+ elif conn_dict ['engine' ]== 'sqlite' :
205+ connformat = "%s:///%s"
206+ conn_string = connformat % (conn_dict ['engine' ], conn_dict ['address' ])
200207 else :
201208 if conn_dict ['engine' ] == 'mssql' :
202209 driver = "pyodbc"
@@ -217,12 +224,19 @@ def _build_connection_string(self, conn_dict):
217224 driver = "None"
218225 conn_string = self .constringBuilder (conn_dict , driver )
219226< << << << HEAD
227+ < << << << HEAD
220228
221229== == == =
222230>> >> >> > logging
223231
224232 # print "******", conn_string
225233 return conn_string
234+ == == == =
235+
236+ # print "******", conn_string
237+ return conn_string
238+
239+ >> >> >> > qualid
226240
227241 def constringBuilder (self , conn_dict , driver ):
228242 if conn_dict ['password' ] is None or not conn_dict ['password' ]:
0 commit comments