1
2
3
4
5
6
7
8
9
10
11 """Update the Rebase emboss files used by Restriction to build the
12 Restriction_Dictionary.py module."""
13
14 import os
15 import sys
16 import time
17 from urllib import FancyURLopener
18
19 from Bio.Restriction.RanaConfig import *
20
21
23
24 - def __init__(self, e_mail='', ftpproxy=''):
40
43
45 print '\n Please wait, trying to connect to Rebase\n'
46 try:
47 self.open(name)
48 except:
49 raise ConnectionError('Rebase')
50 return
51
53 print '\n',
54 for file in self.update(*files):
55 print 'copying', file
56 fn = os.path.basename(file)
57
58 filename = os.path.join(os.getcwd(), fn)
59 print 'to', filename
60 self.retrieve(file, filename)
61 self.close()
62 return
63
65 t = time.gmtime()
66 year = str(t.tm_year)[-1]
67 month = str(t.tm_mon)
68 if len(month) == 1:
69 month = '0' + month
70 return year+month
71
76
78 if hasattr(self, 'tmpcache'):
79 self.close()
80
81
82
83 return
84
85
87
89 print " In order to connect to %s ftp server, you must provide a name.\
90 \n Please edit Bio.Restriction.RanaConfig\n" % which_server
91 sys.exit()
92
93
95
97 print "\n\
98 \n In order to connect to %s ftp server, you must provide a password.\
99 \n Use the --e-mail switch to enter your e-mail address.\
100 \n\n" % which_server
101 sys.exit()
102
103
105
107 print '\
108 \n Unable to connect to the %s ftp server, make sure your computer\
109 \n is connected to the internet and that you have correctly configured\
110 \n the ftp proxy.\
111 \n Use the --proxy switch to enter the address of your proxy\
112 \n' % which_server
113 sys.exit()
114
115
116 __all__ = ['RebaseUpdate', 'FtpNameError', 'FtpPasswordError']
117