CMS 3D CMS Logo

Classes | Functions | Variables
utils Namespace Reference

Classes

class  BinToBin
 
class  BinToBin1percent
 
class  Chi2
 
class  KS
 
class  StatisticalTest
 
class  unpickler
 

Functions

def ask_ok (prompt, retries=4, complaint='yes or no')
 
def code_generator (kwds)
 
def friendly_since (time_type, since)
 
def functor (code, kwds, debug=0)
 
def get_relval_cmssw_version (file)
 
def get_relval_id (file)
 
def get_relval_max_version (files)
 
def get_relval_version (file)
 -------------—— Make files pairs: RelVal utils ---------------—— More...
 
def get_relvaldata_cmssw_version (file)
 
def get_relvaldata_id (file)
 -----------—— Make files pairs: RelValData utils --------------—— More...
 
def get_relvaldata_max_version (files)
 
def get_relvaldata_version (file)
 
def getNbins (h)
 
def is_empty (h)
 
def is_relvaldata (files)
 ----------------------— Make files pairs -----------------------— More...
 
def is_sparse (h)
 
def literal2root (literal, rootType)
 
def logger (msg_level, message)
 
def make_files_pairs (files, verbose=True)
 
def parse_word (word)
 
def profile2histo (profile)
 
def setTDRStyle ()
 
def test_env (tdir, tmpl)
 
def to_datetime (date_string)
 
def to_timestamp (obj)
 
def tree (idir)
 
def user_info (ainput=None)
 
def wget (url)
 

Variables

 _log_level
 
 argv
 
 gErrorIgnoreLevel
 
 theargv
 

Detailed Description

File that contains utility functions used by various modules, but that do not fit into any single module.

Function Documentation

def utils.ask_ok (   prompt,
  retries = 4,
  complaint = 'yes or no' 
)

Definition at line 419 of file utils.py.

419 def ask_ok(prompt, retries=4, complaint='yes or no'):
420  while True:
421  ok = raw_input(prompt)
422  if ok in ('y', 'ye', 'yes'):
423  return True
424  if ok in ('n', 'no'):
425  return False
426  retries = retries - 1
427  if retries < 0:
428  raise IOError('refusenik user')
429  print complaint
430 
431 #-------------------------------------------------------------------------------
432 
def ask_ok(prompt, retries=4, complaint='yes or no')
Definition: utils.py:419
def utils.code_generator (   kwds)
Code generator function, parse user arguments, load and
return appropriate template generator module.

Definition at line 106 of file utils.py.

References str.

Referenced by cms.generate(), and main.generator().

106 def code_generator(kwds):
107  """
108  Code generator function, parse user arguments, load and
109  return appropriate template generator module.
110  """
111  debug = kwds.get('debug', None)
112  if debug:
113  print "Configuration:"
114  pprint.pprint(kwds)
115  try:
116  klass = kwds.get('tmpl')
117  mname = 'FWCore.Skeletons.%s' % klass.lower()
118  module = __import__(mname, fromlist=[klass])
119  except ImportError as err:
120  klass = 'AbstractPkg'
121  module = __import__('FWCore.Skeletons.pkg', fromlist=[klass])
122  if debug:
123  print "%s, will use %s" % (str(err), klass)
124  obj = getattr(module, klass)(kwds)
125  return obj
126 
def code_generator(kwds)
Definition: utils.py:106
#define str(s)
def utils.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 18 of file utils.py.

18 def friendly_since(time_type, since):
19  """
20  Takes a since and, if it is Run-based expressed as Lumi-based,
21  returns the run number.
22  Otherwise, returns the since without transformations.
23  """
24  if time_type == "Run" and (since & 0xffffff) == 0:
25  return since >> 32
26  else:
27  return since
def friendly_since(time_type, since)
Definition: utils.py:18
def utils.functor (   code,
  kwds,
  debug = 0 
)
Auto-generate and execute function with given code and configuration
For details of compile/exec/eval see
http://lucumr.pocoo.org/2011/2/1/exec-in-python/

Definition at line 54 of file utils.py.

References join().

Referenced by pkg.AbstractPkg.write().

54 def functor(code, kwds, debug=0):
55  """
56  Auto-generate and execute function with given code and configuration
57  For details of compile/exec/eval see
58  http://lucumr.pocoo.org/2011/2/1/exec-in-python/
59  """
60  args = []
61  for key, val in kwds.items():
62  if isinstance(val, str):
63  arg = '%s="%s"' % (key, val)
64  elif isinstance(val, list):
65  arg = '%s=%s' % (key, val)
66  else:
67  msg = 'Unsupported data type "%s" <%s>' % (val, type(val))
68  raise Exception(msg)
69  args.append(arg)
70  func = '\nimport sys'
71  func += '\nimport StringIO'
72  func += "\ndef func(%s):\n" % ','.join(args)
73  func += code
74  func += """
75 def capture():
76  "Capture snippet printous"
77  old_stdout = sys.stdout
78  sys.stdout = StringIO.StringIO()
79  func()
80  out = sys.stdout.getvalue()
81  sys.stdout = old_stdout
82  return out\n
83 capture()\n"""
84  if debug:
85  print "\n### generated code\n"
86  print func
87  # compile python code as exec statement
88  obj = compile(func, '<string>', 'exec')
89  # define execution namespace
90  namespace = {}
91  # execute compiled python code in given namespace
92  exec(obj, namespace)
93  # located generated function object, run it and return its results
94  return namespace['capture']()
95 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def functor(code, kwds, debug=0)
Definition: utils.py:54
def utils.get_relval_cmssw_version (   file)

Definition at line 532 of file utils.py.

533  cmssw_release = re.findall('(CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?)-', file)
534  gr_r_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-([\w\d]*)_V\d*\w?(_[\w\d]*)?-v', file)
535  if cmssw_release and gr_r_version:
536  if "PU" in gr_r_version[0][0] and not "FastSim" in file:
537  __gt = re.sub('^[^_]*_', "", gr_r_version[0][0])
538  __process_string = gr_r_version[0][1]
539  return (__gt, __process_string)
540  elif "PU" in gr_r_version[0][0] and "FastSim" in file: #a check for FastSimPU samples
541  return (cmssw_release[0], "PU_") #with possibly different GT's
542  return (cmssw_release[0], gr_r_version[0])
543 
def get_relval_cmssw_version(file)
Definition: utils.py:532
def utils.get_relval_id (   file)
Returns unique relval ID (dataset name) for a given file.

Definition at line 544 of file utils.py.

References edmIntegrityCheck.group.

544 def get_relval_id(file):
545  """Returns unique relval ID (dataset name) for a given file."""
546  dataset_name = re.findall('R\d{9}__([\w\D]*)__CMSSW_', file)
547  __process_string = re.search('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-([\w\d]*)_V\d*\w?(_[\w\d]*)?-v', file)
548  _ps = ""
549  if __process_string:
550  if "PU" in __process_string.group(1) and not "FastSim" in file:
551  _ps = re.search('^[^_]*_', __process_string.group(1)).group()
552  elif "PU" in __process_string.group(1) and "FastSim" in file:
553  return dataset_name[0]+"_", _ps ##some testing is needed
554  return dataset_name[0], _ps
555 
def get_relval_id(file)
Definition: utils.py:544
def utils.get_relval_max_version (   files)
Returns file with maximum version at a) beggining of the file,
e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max.

Definition at line 520 of file utils.py.

References get_relval_version().

521  """Returns file with maximum version at a) beggining of the file,
522  e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max."""
523  max_file = files[0]
524  max_v = get_relval_version(files[0])
525  for file in files:
526  file_v = get_relval_version(file)
527  if file_v[1] > max_v[1] or ((file_v[1] == max_v[1]) and (file_v[0] > max_v[0])):
528  max_file = file
529  max_v = file_v
530  return max_file
531 
def get_relval_version(file)
-------------—— Make files pairs: RelVal utils ---------------——
Definition: utils.py:513
def get_relval_max_version(files)
Definition: utils.py:520
def utils.get_relval_version (   file)

-------------—— Make files pairs: RelVal utils ---------------——

Returns tuple (CMSSW version, run version) for specified file.

Definition at line 513 of file utils.py.

References createfilelist.int.

Referenced by get_relval_max_version().

514  """Returns tuple (CMSSW version, run version) for specified file."""
515  cmssw_version = re.findall('DQM_V(\d*)_', file)
516  run_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-[\w\d]*_V\d*\w?(?:_[\w\d]*)?-v(\d*)__', file)
517  if cmssw_version and run_version:
518  return (int(cmssw_version[0]), int(run_version[0]))
519 
def get_relval_version(file)
-------------—— Make files pairs: RelVal utils ---------------——
Definition: utils.py:513
def utils.get_relvaldata_cmssw_version (   file)
Returns tuple (CMSSW release, GR_R version) for specified RelValData file.

Definition at line 482 of file utils.py.

483  """Returns tuple (CMSSW release, GR_R version) for specified RelValData file."""
484  cmssw_release = re.findall('(CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?)-', file)
485  gr_r_version = re.findall('-(GR_R_\d*_V\d*\w?)(?:_RelVal)?_', file)
486  if not gr_r_version:
487  gr_r_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-(\w*)_RelVal_', file)
488  if cmssw_release and gr_r_version:
489  return (cmssw_release[0], gr_r_version[0])
490 
def get_relvaldata_cmssw_version(file)
Definition: utils.py:482
def utils.get_relvaldata_id (   file)

-----------—— Make files pairs: RelValData utils --------------——

Returns unique relvaldata ID for a given file.

Definition at line 472 of file utils.py.

473  """Returns unique relvaldata ID for a given file."""
474  run_id = re.search('R\d{9}', file)
475  run = re.search('_RelVal_([\w\d]*)-v\d__', file)
476  if not run:
477  run = re.search('GR_R_\d*_V\d*C?_([\w\d]*)-v\d__', file)
478  if run_id and run:
479  return (run_id.group(), run.group(1))
480  return None
481 
def get_relvaldata_id(file)
-----------—— Make files pairs: RelValData utils --------------——
Definition: utils.py:472
def utils.get_relvaldata_max_version (   files)
Returns file with maximum version at a) beggining of the file,
e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max.

Definition at line 500 of file utils.py.

References get_relvaldata_version().

501  """Returns file with maximum version at a) beggining of the file,
502  e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max."""
503  max_file = files[0]
504  max_v = get_relvaldata_version(files[0])
505  for file in files:
506  file_v = get_relvaldata_version(file)
507  if file_v[1] > max_v[1] or ((file_v[1] == max_v[1]) and (file_v[0] > max_v[0])):
508  max_file = file
509  max_v = file_v
510  return max_file
511 
def get_relvaldata_version(file)
Definition: utils.py:491
def get_relvaldata_max_version(files)
Definition: utils.py:500
def utils.get_relvaldata_version (   file)
Returns tuple (CMSSW version, run version) for specified file.

Definition at line 491 of file utils.py.

References createfilelist.int.

Referenced by get_relvaldata_max_version().

492  """Returns tuple (CMSSW version, run version) for specified file."""
493  cmssw_version = re.findall('DQM_V(\d*)_', file)
494  run_version = re.findall('_RelVal_[\w\d]*-v(\d)__', file)
495  if not run_version:
496  run_version = re.findall('GR_R_\d*_V\d*C?_[\w\d]*-v(\d)__', file)
497  if cmssw_version and run_version:
498  return (int(cmssw_version[0]), int(run_version[0]))
499 
def get_relvaldata_version(file)
Definition: utils.py:491
def utils.getNbins (   h)

Definition at line 89 of file utils.py.

Referenced by utils.Chi2.absval(), utils.BinToBin.do_test(), utils.BinToBin1percent.do_test(), and utils.StatisticalTest.get_rank().

89 def getNbins(h):
90  biny=h.GetNbinsY()
91  if biny>1:biny+=1
92  binz=h.GetNbinsZ()
93  if binz>1:binz+=1
94  return (h.GetNbinsX()+1)*(biny)*(binz)
95 
96 #-------------------------------------------------------------------------------
97 
98 
def getNbins(h)
Definition: utils.py:89
def utils.is_empty (   h)

Definition at line 167 of file utils.py.

Referenced by DTSectColl.addTSTheta(), and utils.StatisticalTest.get_rank().

167 def is_empty(h):
168  for i in xrange(1,getNbins(h)):
169  if h.GetBinContent(i)!=0: return False
170  return True
171  #return h.GetSumOfWeights()==0
172 
173 #-------------------------------------------------------------------------------
174 
def getNbins(h)
Definition: utils.py:89
def is_empty(h)
Definition: utils.py:167
def utils.is_relvaldata (   files)

----------------------— Make files pairs -----------------------—

Definition at line 557 of file utils.py.

References any().

Referenced by make_files_pairs().

557 def is_relvaldata(files):
558  is_relvaldata_re = re.compile('_RelVal_')
559  return any([is_relvaldata_re.search(filename) for filename in files])
560 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def is_relvaldata(files)
----------------------— Make files pairs -----------------------—
Definition: utils.py:557
def utils.is_sparse (   h)

Definition at line 175 of file utils.py.

175 def is_sparse(h):
176  filled_bins=0.
177  nbins=h.GetNbinsX()
178  for ibin in xrange(nbins):
179  if h.GetBinContent(ibin)>0:
180  filled_bins+=1
181  #print "%s %s --> %s" %(filled_bins,nbins,filled_bins/nbins)
182  if filled_bins/nbins < .5:
183  return True
184  else:
185  return False
186 
187 #-------------------------------------------------------------------------------
188 
def is_sparse(h)
Definition: utils.py:175
def utils.literal2root (   literal,
  rootType 
)

Definition at line 66 of file utils.py.

66 def literal2root (literal,rootType):
67  bitsarray = array.array('B')
68  bitsarray.fromstring(literal.decode('hex'))
69 
70  tbuffer=0
71  try:
72  tbuffer = TBufferFile(TBufferFile.kRead, len(bitsarray), bitsarray, False,0)
73  except:
74  print "could not transform to object array:"
75  print [ i for i in bitsarray ]
76 
77  # replace a couple of shortcuts with the real root class name
78  if rootType == 'TPROF':
79  rootType = 'TProfile'
80  if rootType == 'TPROF2D':
81  rootType = 'TProfile2D'
82 
83  root_class=eval(rootType+'.Class()')
84 
85  return tbuffer.ReadObject(root_class)
86 
87 #-------------------------------------------------------------------------------
88 
def literal2root(literal, rootType)
Definition: utils.py:66
def utils.logger (   msg_level,
  message 
)

Definition at line 44 of file utils.py.

44 def logger(msg_level,message):
45  if msg_level>=_log_level:
46  print "[%s] %s" %(asctime(),message)
47 
48 #-------------------------------------------------------------------------------
def logger(msg_level, message)
Definition: utils.py:44
def utils.make_files_pairs (   files,
  verbose = True 
)

Definition at line 561 of file utils.py.

References mps_setup.append, cmsPerfStripChart.dict, cmsRelvalreport.exit, is_relvaldata(), SiStripPI.max, and str.

Referenced by ValidationMatrix.get_filenames_from_pool().

561 def make_files_pairs(files, verbose=True):
562  ## Select functions to use
563  if is_relvaldata(files):
564  is_relval_data = True
565  get_cmssw_version = get_relvaldata_cmssw_version
566  get_id = get_relvaldata_id
567  get_max_version = get_relvaldata_max_version
568  # print 'Pairing Data RelVal files.'
569  else:
570  is_relval_data = False
571  get_cmssw_version = get_relval_cmssw_version
572  get_id = get_relval_id
573  get_max_version = get_relval_max_version
574  # print 'Pairing Monte Carlo RelVal files.'
575 
576  ## Divide files into groups
577  versions_files = dict()
578  for file in files:
579  version = get_cmssw_version(file)
580  if version in versions_files:
581  versions_files[version].append(file)
582  else:
583  versions_files[version] = [file]
584 
585  ## Print the division into groups
586  if verbose:
587  print '\nFound versions:'
588  for version in versions_files:
589  print '%s: %d files' % (str(version), len(versions_files[version]))
590 
591  if len(versions_files) <= 1:
592  print '\nFound too little versions, there is nothing to pair. Exiting...\n'
593  exit()
594 
595  ## Select two biggest groups.
596  versions = versions_files.keys()
597  sizes = [len(value) for value in versions_files.values()]
598  v1 = versions[sizes.index(max(sizes))]
599  versions.remove(v1)
600  sizes.remove(max(sizes))
601  v2 = versions[sizes.index(max(sizes))]
602 
603  ## Print two biggest groups.
604  if verbose:
605  print '\nPairing %s (%d files) and %s (%d files)' % (str(v1),
606  len(versions_files[v1]), str(v2), len(versions_files[v2]))
607 
608  ## Pairing two versions
609  print '\nGot pairs:'
610  pairs = []
611  for unique_id in set([get_id(file) for file in versions_files[v1]]):
612  if is_relval_data:
613  dataset_re = re.compile(unique_id[0]+'_')
614  run_re = re.compile(unique_id[1])
615  c1_files = [file for file in versions_files[v1] if dataset_re.search(file) and run_re.search(file)]
616  c2_files = [file for file in versions_files[v2] if dataset_re.search(file) and run_re.search(file)]
617  else:
618  dataset_re = re.compile(unique_id[0]+'_')
619  ps_re = re.compile(unique_id[1])
620  ##compile a PU re and search also for same PU
621  c1_files = [file for file in versions_files[v1] if dataset_re.search(file) and ps_re.search(file)]
622  c2_files = [file for file in versions_files[v2] if dataset_re.search(file) and ps_re.search(file)]
623 
624  if len(c1_files) > 0 and len(c2_files) > 0:
625  first_file = get_max_version(c1_files)
626  second_file = get_max_version(c2_files)
627  print '%s\n%s\n' % (first_file, second_file)
628  pairs.extend((first_file, second_file))
629  if verbose:
630  print "Paired and got %d files.\n" % len(pairs)
631  return pairs
632 
def is_relvaldata(files)
----------------------— Make files pairs -----------------------—
Definition: utils.py:557
def make_files_pairs(files, verbose=True)
Definition: utils.py:561
#define str(s)
def utils.parse_word (   word)

Definition at line 21 of file utils.py.

Referenced by pkg.AbstractPkg.tmpl_tags().

21 def parse_word(word):
22  "Parse word which contas double underscore tag"
23  output = set()
24  words = word.split()
25  for idx in xrange(0, len(words)):
26  pat = words[idx]
27  if pat and len(pat) > 4 and pat[:2] == '__': # we found enclosure
28  tag = pat[2:pat.rfind('__')]
29  if tag.find('__') != -1: # another pattern
30  for item in tag.split('__'):
31  if TAG.match(item):
32  output.add('__%s__' % item)
33  else:
34  output.add('__%s__' % tag)
35  return output
36 
def parse_word(word)
Definition: utils.py:21
def utils.profile2histo (   profile)

Definition at line 216 of file utils.py.

216 def profile2histo(profile):
217  if not profile.InheritsFrom("TH1"):
218  return profile
219 
220  bin_low_edges=[]
221  n_bins=profile.GetNbinsX()
222 
223  for ibin in xrange(1,n_bins+2):
224  bin_low_edges.append(profile.GetBinLowEdge(ibin))
225  bin_low_edges=array.array('f',bin_low_edges)
226  histo=TH1F(profile.GetName(),profile.GetTitle(),n_bins,bin_low_edges)
227  for ibin in xrange(0,n_bins+1):
228  histo.SetBinContent(ibin,profile.GetBinContent(ibin))
229  histo.SetBinError(ibin,profile.GetBinError(ibin))
230 
231  return histo
232 #-------------------------------------------------------------------------------
233 
def profile2histo(profile)
Definition: utils.py:216
def utils.setTDRStyle ( )

Definition at line 49 of file utils.py.

References compare_using_db.dirname.

49 def setTDRStyle():
50  this_dir=dirname(this_module_name)
51  this_dir_one_up=this_dir[:this_dir.rfind("/")+1]
52  #this_dir_two_up=this_dir_one_up[:this_dir_one_up.rfind("/")+1]
53  style_file=''
54  if "RELMON_SA" in os.environ:
55  style_file=this_dir_one_up+"data/tdrstyle_mod.C"
56  else:
57  style_file="%s/src/Utilities/RelMon/data/tdrstyle_mod.C"%(os.environ["CMSSW_BASE"])
58  try:
59  gROOT.ProcessLine(".L %s" %style_file)
60  gROOT.ProcessLine("setTDRStyle()")
61  except:
62  "Print could not set the TDR style. File %s not found?" %style_file
63 
64 
65 #-------------------------------------------------------------------------------
def setTDRStyle()
Definition: utils.py:49
def utils.test_env (   tdir,
  tmpl 
)
Test user environment, look-up if user has run cmsenv, otherwise
provide meaningful error message back to the user.

Definition at line 37 of file utils.py.

Referenced by main.generator().

37 def test_env(tdir, tmpl):
38  """
39  Test user environment, look-up if user has run cmsenv, otherwise
40  provide meaningful error message back to the user.
41  """
42  if not tdir or not os.path.isdir(tdir):
43  print "Unable to access template dir: %s" % tdir
44  sys.exit(1)
45  if not os.listdir(tdir):
46  print "No template files found in template dir %s" % tdir
47  sys.exit(0)
48  if not tmpl:
49  msg = "No template type is provided, "
50  msg += "see available templates via --templates option"
51  print msg
52  sys.exit(1)
53 
def test_env(tdir, tmpl)
Definition: utils.py:37
def utils.to_datetime (   date_string)
Takes a date string with the format Y-m-d H:m:S.f and gives back a datetime.datetime object

Definition at line 12 of file utils.py.

Referenced by querying_tests.global_tag_tests().

12 def to_datetime(date_string):
13  """
14  Takes a date string with the format Y-m-d H:m:S.f and gives back a datetime.datetime object
15  """
16  return datetime.datetime.strptime(date_string.replace(",", "."), "%Y-%m-%d %H:%M:%S.%f")
17 
def to_datetime(date_string)
Definition: utils.py:12
def utils.to_timestamp (   obj)
Takes a datetime object and outputs a timestamp string with the format Y-m-d H:m:S.f

Definition at line 6 of file utils.py.

Referenced by uploads.uploader.filter_iovs_by_fcsr(), models.generate(), uploads.log(), and uploads.uploader.send_blob().

6 def to_timestamp(obj):
7  """
8  Takes a datetime object and outputs a timestamp string with the format Y-m-d H:m:S.f
9  """
10  return obj.strftime('%Y-%m-%d %H:%M:%S.%f') if isinstance(obj, datetime.datetime) else obj
11 
def to_timestamp(obj)
Definition: utils.py:6
def utils.tree (   idir)

Definition at line 127 of file utils.py.

127 def tree(idir):
128  "Print directory content, similar to tree UNIX command"
129  if idir[-1] == '/':
130  idir = idir[-1]
131  dsep = ''
132  fsep = ''
133  dtot = -1 # we'll not count initial directory
134  ftot = 0
135  for root, dirs, files in os.walk(idir):
136  dirs = root.split('/')
137  ndirs = len(dirs)
138  if ndirs > 1:
139  dsep = '| '*(ndirs-1)
140  print '%s%s/' % (dsep, dirs[-1])
141  dtot += 1
142  for fname in files:
143  fsep = dsep + '|--'
144  print '%s %s' % (fsep, fname)
145  ftot += 1
146  if dtot == -1 or not dtot:
147  dmsg = ''
148  else:
149  dmsg = '%s directories,' % dtot
150  if ftot:
151  fmsg = '%s file' % ftot
152  if ftot > 1:
153  fmsg += 's'
154  else:
155  fmsg = ''
156  if dmsg and fmsg:
157  print "Total: %s %s" % (dmsg, fmsg)
158  else:
159  print "No directories/files in %s" % idir
160 
def tree(idir)
Definition: utils.py:127
def utils.user_info (   ainput = None)

Definition at line 96 of file utils.py.

96 def user_info(ainput=None):
97  "Return user name and office location, based on UNIX finger"
98  if ainput:
99  return ainput
100  pwdstr = pwd.getpwnam(os.getlogin())
101  author = pwdstr.pw_gecos
102  if author and isinstance(author, str):
103  author = author.split(',')[0]
104  return author
105 
def user_info(ainput=None)
Definition: utils.py:96
def utils.wget (   url)
Fetch the WHOLE file, not in bunches... To be optimised.

Definition at line 447 of file utils.py.

References estimatePileup.basename.

447 def wget(url):
448  """ Fetch the WHOLE file, not in bunches... To be optimised.
449  """
450  opener=build_opener(X509CertOpen())
451  datareq = Request(url)
452  datareq.add_header('authenticated_wget', "The ultimate wgetter")
453  bin_content=None
454  try:
455  filename=basename(url)
456  print "Checking existence of file %s on disk..."%filename
457  if not isfile("./%s"%filename):
458  bin_content=opener.open(datareq).read()
459  else:
460  print "File %s exists, skipping.." %filename
461  except ValueError:
462  print "Error: Unknown url %s" %url
463 
464  if bin_content!=None:
465  ofile = open(filename, 'wb')
466  ofile.write(bin_content)
467  ofile.close()
468 
469 #-------------------------------------------------------------------------------
def wget(url)
Definition: utils.py:447

Variable Documentation

utils._log_level
private

Definition at line 43 of file utils.py.

utils.argv

Definition at line 22 of file utils.py.

utils.gErrorIgnoreLevel

Definition at line 25 of file utils.py.

Referenced by main(), FWFileEntry.openFile(), TkAlStyle.set(), and topLevelPSet().

utils.theargv

Definition at line 21 of file utils.py.