13 Just a draft of the real program...It is very ugly still.
15 from __future__
import print_function
18 from os.path
import basename
19 from optparse
import OptionParser
22 from urllib2
import Request,build_opener,urlopen
25 if "RELMON_SA" in os.environ:
26 from authentication
import X509CertOpen
27 from definitions
import server
28 from utils
import wget
30 from Utilities.RelMon.authentication
import X509CertOpen
32 from Utilities.RelMon.utils
import wget
36 for line
in page_html.split(
"<tr><td>")[1:]:
39 link_start=line.find(
"href='")+6
40 link_end=line.find(
"'>")
43 name_end=line.find(
"</a>")
45 contents.append(the_server+line[link_start:link_end])
47 contents.append(line[name_start:name_end])
51 """ Get the web page listing the rootfiles. Use the X509 auth.
54 datareq = Request(url)
55 datareq.add_header(
'authenticated_wget',
"The ultimate wgetter")
56 filename=basename(url)
57 return opener.open(datareq).
read()
59 if __name__==
"__main__":
61 parser = OptionParser(usage=
"usage: %prog [options] dirtolist")
63 parser.add_option(
"-d",
"--dev",
67 help=
"Select the development GUI instance.")
69 parser.add_option(
"--offline",
73 help=
"Select the Offline GUI instance.")
75 parser.add_option(
"-o",
"--online",
79 help=
"Select the Online GUI instance.")
81 parser.add_option(
"-r",
"--relval",
85 help=
"Select the RelVal GUI instance.")
87 parser.add_option(
"-u",
"--show_url",
91 help=
"Show the full URL of the file.")
93 parser.add_option(
"-g",
"--get",
97 help=
"Get the files.")
99 parser.add_option(
"-p",
"--path",
103 help=
"The path to be matched before getting.")
105 (options, args) = parser.parse_args()
107 if not(options.development
or options.offline
or options.online
or options.relval):
108 print(
"Select development or online instance!")
113 print(
"Please specify only one directory to list!")
123 if options.development:
127 directory=
"%s/dqm/%s/data/browse/%s" %(server,mode,dirtolist)
128 print(
"peeping ",directory)
132 print(
"No contents found!")
134 for content
in contents:
135 if not options.get
and search(options.path,content):
137 if options.get
and options.show_url
and len(options.path)>0
and search(options.path,content):
138 if not search(
'pre',options.path)
and search(
'pre',content):
140 bcontent=basename(content)
141 print(
"Getting %s" %bcontent)
143 print(
"Got %s!!" %bcontent)