16 Just a draft of the real program...It is very ugly still.
20 from os.path
import basename
21 from optparse
import OptionParser
24 from urllib2
import Request,build_opener,urlopen
27 if os.environ.has_key(
"RELMON_SA"):
28 from authentication
import X509CertOpen
29 from definitions
import server
30 from utils
import wget
32 from Utilities.RelMon.authentication
import X509CertOpen
34 from Utilities.RelMon.utils
import wget
38 for line
in page_html.split(
"<tr><td>")[1:]:
41 link_start=line.find(
"href='")+6
42 link_end=line.find(
"'>")
45 name_end=line.find(
"</a>")
47 contents.append(the_server+line[link_start:link_end])
49 contents.append(line[name_start:name_end])
53 """ Get the web page listing the rootfiles. Use the X509 auth.
56 datareq = Request(url)
57 datareq.add_header(
'authenticated_wget',
"The ultimate wgetter")
58 filename=basename(url)
59 return opener.open(datareq).
read()
61 if __name__==
"__main__":
63 parser = OptionParser(usage=
"usage: %prog [options] dirtolist")
65 parser.add_option(
"-d",
"--dev",
69 help=
"Select the development GUI instance.")
71 parser.add_option(
"--offline",
75 help=
"Select the Offline GUI instance.")
77 parser.add_option(
"-o",
"--online",
81 help=
"Select the Online GUI instance.")
83 parser.add_option(
"-r",
"--relval",
87 help=
"Select the RelVal GUI instance.")
89 parser.add_option(
"-u",
"--show_url",
93 help=
"Show the full URL of the file.")
95 parser.add_option(
"-g",
"--get",
99 help=
"Get the files.")
101 parser.add_option(
"-p",
"--path",
105 help=
"The path to be matched before getting.")
107 (options, args) = parser.parse_args()
109 if not(options.development
or options.offline
or options.online
or options.relval):
110 print "Select development or online instance!"
115 print "Please specify only one directory to list!"
125 if options.development:
129 directory=
"%s/dqm/%s/data/browse/%s" %(server,mode,dirtolist)
130 print "peeping ",directory
134 print "No contents found!"
136 for content
in contents:
137 if not options.get
and search(options.path,content):
139 if options.get
and options.show_url
and len(options.path)>0
and search(options.path,content):
140 if not search(
'pre',options.path)
and search(
'pre',content):
142 bcontent=basename(content)
143 print "Getting %s" %bcontent
145 print "Got %s!!" %bcontent