~ma5/madanalysis5/madanalysis-development

72.1.53 by Eric Conte
new install architecture
1
################################################################################
2
#  
123 by Benjamin Fuks
updating copyrights
3
#  Copyright (C) 2012-2018 Eric Conte, Benjamin Fuks
72.1.53 by Eric Conte
new install architecture
4
#  The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
5
#  
6
#  This file is part of MadAnalysis 5.
7
#  Official website: <https://launchpad.net/madanalysis5>
8
#  
9
#  MadAnalysis 5 is free software: you can redistribute it and/or modify
10
#  it under the terms of the GNU General Public License as published by
11
#  the Free Software Foundation, either version 3 of the License, or
12
#  (at your option) any later version.
13
#  
14
#  MadAnalysis 5 is distributed in the hope that it will be useful,
15
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
#  GNU General Public License for more details.
18
#  
19
#  You should have received a copy of the GNU General Public License
20
#  along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
21
#  
22
################################################################################
23
24
25
from madanalysis.install.install_service import InstallService
26
from shell_command import ShellCommand
27
import os
28
import sys
29
import logging
30
31
class InstallSamples:
32
33
    def __init__(self,main):
34
        self.main       = main
35
        self.installdir = os.path.normpath(self.main.archi_info.ma5dir+'/samples')
36
        self.files = { "ttbar_fh.lhe.gz" :   "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/samples/ttbar_fh.lhe.gz",\
37
                       "ttbar_sl_1.lhe.gz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/samples/ttbar_sl_1.lhe.gz",\
38
                       "ttbar_sl_2.lhe.gz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/samples/ttbar_sl_2.lhe.gz",\
39
                       "zz.lhe.gz" :         "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/samples/zz.lhe.gz" }
40
41
42
    def Detect(self):
43
        if not os.path.isdir(self.installdir):
112.1.50 by Eric Conte
update all-file with MA5banner + logging.getLogger(MA5)
44
            logging.getLogger('MA5').debug("The folder "+self.installdir+"' is not found")
72.1.53 by Eric Conte
new install architecture
45
            return False
46
        return True
47
48
49
    def Remove(self,question=True):
50
        from madanalysis.IOinterface.folder_writer import FolderWriter
51
        return FolderWriter.RemoveDirectory(self.installdir,question)
52
53
54
    def CreatePackageFolder(self):
55
        return InstallService.create_package_folder(self.main.archi_info.ma5dir,'samples')
56
57
58
    def Download(self):
59
        # Checking connection with MA5 web site
60
        if not InstallService.check_ma5site():
61
            return False
62
        # Launching wget
63
        logname = os.path.normpath(self.installdir+'/wget.log')
64
        if not InstallService.wget(self.files,logname,self.installdir):
65
            return False
66
        # Ok
67
        return True
68
69
70
    def Check(self):
71
72
        filesToCheck = self.files.keys()
73
        ok=True
74
        for item in filesToCheck:
112.1.50 by Eric Conte
update all-file with MA5banner + logging.getLogger(MA5)
75
            logging.getLogger('MA5').debug('checking file: '+item+ ' ...')
72.1.53 by Eric Conte
new install architecture
76
            filename=os.path.normpath(self.installdir+'/'+item)
77
            if not os.path.isfile(filename):
112.1.50 by Eric Conte
update all-file with MA5banner + logging.getLogger(MA5)
78
                logging.getLogger('MA5').error('file called "'+filename+'" is not found')
72.1.53 by Eric Conte
new install architecture
79
                ok=False
80
        return ok
81
82
    def NeedToRestart(self):
83
        return False
84
    
85