@@ -157,6 +157,71 @@ def execute(self, log_out, log_err):
157
157
return proc .returncode
158
158
159
159
160
+
161
+ class SQLiteProc (Component ):
162
+ """!
163
+ Copy the SQLite database file to the desired location.
164
+ """
165
+
166
+ def __init__ (self , ** kwargs ):
167
+ """!
168
+ Initialize SQLiteProc to copy the SQLite file.
169
+ """
170
+ self .source_file = kwargs .get ('source_file' )
171
+ self .destination_file = kwargs .get ('destination_file' )
172
+
173
+ #You can set this under for .hpsmc file to point to a specific local database. For me I used the following in .hpsmc
174
+ #[EvioToLcio]
175
+ #hps_java_bin_jar = /home/zshi/.m2/repository/org/hps/hps-distribution/5.2.2-SNAPSHOT/hps-distribution-5.2.2-SNAPSHOT-bin.jar
176
+ #java_args = -Xmx3g -XX:+UseSerialGC -Dorg.sqlite.tmpdir=/w/hallb-scshelf2102/hps/zshi/swiftjob/SQLite/LocalTest/tmp/ -Dorg.hps.conditions.url=jdbc:sqlite:hps_conditions_2025_03_06.sqlite
177
+ #[SQLiteProc]
178
+ #source_file = /w/hallb-scshelf2102/hps/zshi/swiftjob/SQLite/LocalTest/hps_conditions_2025_03_06.sqlite
179
+ #destination_file = ./hps_conditions_2025_03_06.sqlite
180
+
181
+
182
+ if self .source_file is not None :
183
+ self .logger .debug ("Setting SQLite local copy source file from config: %s" + self .source_file )
184
+ args .append (self .source_file )
185
+ if self .destination_file is not None :
186
+ self .logger .debug ('Setting Job Destination file from config: %s' % self .destination_file )
187
+ args .append ('-Dorg.hps.conditions.url=%s' % self .destination_file )
188
+
189
+ # Ensure to call the parent constructor properly
190
+ Component .__init__ (self , name = 'sqlite_file_copy' , ** kwargs )
191
+
192
+
193
+ def cmd_args (self ):
194
+ """!
195
+ Return dummy command arguments to satisfy the parent class.
196
+ """
197
+ cmd_args = ["(no-command-needed)" ]
198
+
199
+ if not all (isinstance (arg , str ) for arg in cmd_args ):
200
+ raise ValueError ("All arguments must be strings." )
201
+ # return ["(no-command-needed)"]
202
+ return ['--source' , self .source_file , '--destination' , self .destination_file ]
203
+
204
+ def execute (self , log_out , log_err ):
205
+ """!
206
+ Execute the file copy operation.
207
+ """
208
+
209
+ try :
210
+ # Copy the file
211
+
212
+ self .logger .info (f"Copying file from { self .source_file } to { self .destination_file } " )
213
+ shutil .copy (self .source_file , self .destination_file )
214
+
215
+ # Log success
216
+ self .logger .info (f"Successfully copied file to { self .destination_file } " )
217
+
218
+ return 0 # Success code
219
+
220
+ except Exception as e :
221
+ self .logger .error (f"Error during file copy: { e } " )
222
+ return 1 # Error code
223
+
224
+
160
225
class JobManager (Component ):
161
226
"""!
162
227
Run the hps-java JobManager class.
0 commit comments