Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:43

0001 import sqlite3
0002 import json
0003 import subprocess
0004 import shutil
0005 
0006 # Open the SQLite database file
0007 conn = sqlite3.connect('test_myTagName.db')
0008 cursor = conn.cursor()
0009 
0010 # Execute the SELECT query
0011 cursor.execute('SELECT * FROM IOV')
0012 
0013 # Fetch all the results from the query
0014 results = cursor.fetchall()
0015 
0016 # Create an empty list to store the extracted values
0017 extracted_values = []
0018 
0019 # Extract the desired part of the string and add it to the list
0020 for row in results:
0021     value = row[0].split('|')[0].strip()
0022     extracted_values.append(value)
0023 
0024 # Close the database connection
0025 conn.close()
0026 
0027 # Generate the JSON file and execute the command for each extracted value
0028 for value in extracted_values:
0029     print("uploading",value)
0030     # Create the dictionary for the JSON structure
0031     data = {
0032         "destinationDatabase": "oracle://cms_orcoff_prep/CMS_CONDITIONS",
0033         "destinationTags": {
0034             "SimBeamSpot_" + value + "_v1_mc": {}
0035         },
0036         "inputTag": value,
0037         "since": None,
0038         "userText": value
0039     }
0040     
0041     # Generate the JSON file
0042     filename = "test_myTagName.txt"
0043     with open(filename, 'w') as file:
0044         json.dump(data, file, indent=4)
0045     
0046     # Execute the command to upload conditions
0047     subprocess.call(["uploadConditions.py", "test_myTagName.db"])
0048 
0049     # Generate the new filename
0050     new_filename = "test_" + value + ".txt"
0051     
0052     # Move the file to the new name
0053     shutil.move(filename, new_filename)
0054 
0055     # Print a success message
0056     print("Uploaded conditions for value:", value)