export_Amodels.py 1.67 KB
Newer Older
nsoler's avatar
nsoler committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Nico 11 Feb 2021
# export sign1 models into the cc code repo directory:

import os, shutil, glob

from get_repo_version import cc_repo_version

def export_models(destination, cctype='sign1', cc_repo=None):


    if cc_repo is None:
        cc_repo = cc_repo_version()

        if cc_repo is None:
            print("ERROR, cannot guess the latest cc repository path")
            print("Please provide it as an argument")
            print("ex: cc_repo='/aloy/web_checker/package_cc/2020_02'")
            return
        else:
            print("Working with cc_repo:",cc_repo)


    for space in ['A'+str(n) for n in range(1,6)]:
nsoler's avatar
nsoler committed
24
        ds= space+'.001'
nsoler's avatar
nsoler committed
25
26
27
28
29
30
31
32
33
34
35
        dirModels= os.path.join(cc_repo,'reference', 'A', space, ds, cctype,'models')
        dirtmp= os.path.join(destination,ds,cctype)

        if not os.path.exists(dirtmp):
            try:
                os.makedirs(dirtmp)
            except Exception as e:
                print("ERROR while attempting to create destination folder", dirtmp)
                print(e)
                continue
            else:
nsoler's avatar
nsoler committed
36
                print("Created directory", dirtmp)
nsoler's avatar
nsoler committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

        for fichero in glob.glob(dirModels):
            if fichero != 'fit.ready':
                source= os.path.join(dirModels,fichero)
                target= os.path.join(dirtmp,fichero)
                try:
                    shutil.copyfile(source, target)
                except Exception as e:
                    print(e)
                else:
                    print("Copied:", source, 'to' , target)

if __name__=='__main__':

    destination = "/home/nsoler/CODE/chemical_checker/package/chemicalchecker/util/models/2020_02"
    export_models(destination=destination)