~maddevelopers/mg5amcnlo/2.6.3_rwgt

« back to all changes in this revision

Viewing changes to models/import_ufo.py

  • Committer: olivier-mattelaer
  • Date: 2018-04-29 08:10:16 UTC
  • mfrom: (275.1.80 2.6.2)
  • Revision ID: olivier-mattelaer-20180429081016-9nmfvn1er0zjb23o
pass to 2.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
        Please check your internet connection or retry later'''
118
118
    return data
119
119
 
120
 
def import_model_from_db(model_name):
 
120
def import_model_from_db(model_name, local_dir=False):
121
121
    """ import the model with a given name """
122
122
 
123
123
    data =get_model_db()
135
135
    # 1. PYTHONPATH containing UFO
136
136
    # 2. models directory
137
137
    target = None 
138
 
    if 'PYTHONPATH' in os.environ:
 
138
    if 'PYTHONPATH' in os.environ and not local_dir:
139
139
        for directory in os.environ['PYTHONPATH'].split(':'):
140
140
            if 'UFO' in os.path.basename(directory) and os.path.exists(directory):
141
141
                target= directory 
146
146
    except Exception:
147
147
        pass
148
148
    logger.info("download model from %s to the following directory: %s", link, target, '$MG:color:BLACK')
149
 
    if sys.platform == "darwin":
150
 
        misc.call(['curl', link, '-otmp.tgz'], cwd=target)
151
 
    else:
152
 
        misc.call(['wget', link, '--output-document=tmp.tgz'], cwd=target)
 
149
    misc.wget(link, 'tmp.tgz', cwd=target)
153
150
 
154
151
    #untar the file.
155
152
    # .tgz
156
 
    if link.endswith(('.tgz','.tar.gz')):
 
153
    if link.endswith(('.tgz','.tar.gz','.tar')):
157
154
        try:
158
155
            proc = misc.call('tar -xzpvf tmp.tgz', shell=True, cwd=target)#, stdout=devnull, stderr=devnull)
159
156
            if proc: raise Exception
1242
1239
                    
1243
1240
        return  '' if sign ==1 else '-'
1244
1241
 
1245
 
 
1246
 
 
1247
 
    
1248
1242
    def add_lorentz(self, name, spins , expr):
1249
1243
        """ Add a Lorentz expression which is not present in the UFO """
1250
1244