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