CMS 3D CMS Logo

Classes | Functions
uploads Namespace Reference

Classes

class  output
 
class  uploader
 

Functions

def friendly_since (time_type, since)
 
def log (file_handle, message)
 
def new_log_file_id ()
 

Detailed Description

Joshua Dawes - CERN, CMS - The University of Manchester

This module holds classes to help with uploading conditions to the drop box web service, which also uses CondDBFW to read and write data.

Function Documentation

def uploads.friendly_since (   time_type,
  since 
)
Takes a since and, if it is Run-based expressed as Lumi-based, returns the run number.
Otherwise, returns the since without transformations.

Definition at line 30 of file uploads.py.

Referenced by uploads.uploader.filter_iovs_by_fcsr().

30 def friendly_since(time_type, since):
31  """
32  Takes a since and, if it is Run-based expressed as Lumi-based, returns the run number.
33  Otherwise, returns the since without transformations.
34  """
35  if time_type == "Run" and (since & 0xffffff) == 0:
36  return since >> 32
37  else:
38  return since
39 
40 # this is simple, and works for now - if logging requirements change, I will write a logging class to manage logging
def friendly_since(time_type, since)
Definition: uploads.py:30
def uploads.log (   file_handle,
  message 
)
Very simple logging function, used by output class.

Definition at line 41 of file uploads.py.

References utils.to_timestamp().

Referenced by uploads.output.write().

41 def log(file_handle, message):
42  """
43  Very simple logging function, used by output class.
44  """
45  file_handle.write("[%s] %s\n" % (to_timestamp(datetime.now()), message))
46 
def to_timestamp(obj)
Definition: utils.py:6
def log(file_handle, message)
Definition: uploads.py:41
def uploads.new_log_file_id ( )
Find a new client-side log file name.

Note: This cannot use the upload session token since logs need to be written before this is opened.
However, this can be changed so that the filename that uses the token is written to once
it is obtained.

Definition at line 47 of file uploads.py.

48  """
49  Find a new client-side log file name.
50 
51  Note: This cannot use the upload session token since logs need to be written before this is opened.
52  However, this can be changed so that the filename that uses the token is written to once
53  it is obtained.
54  """
55  # new id = number of log files + 1
56  # (primitive - matching the hash of the upload session may be a better idea)
57  log_files = [file for file in os.listdir(os.path.join(os.getcwd(), "upload_logs")) if "upload_log" in file]
58  new_id = len(log_files)+1
59  return new_id
60 
def new_log_file_id()
Definition: uploads.py:47