[Bio] / FigKernelPackages / FIG.py Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIG.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Mon Feb 23 17:18:19 2004 UTC revision 1.8, Wed Apr 28 21:59:32 2004 UTC
# Line 5  Line 5 
5  import re  import re
6  import FIG_Config  import FIG_Config
7    
8    import Clearinghouse
9    
10    def get_clearinghouse(url = None):
11        return Clearinghouse.Clearinghouse(url)
12    
13  def get_local_hostname():  def get_local_hostname():
14      #      #
15        # See if there is a FIGdisk/config/hostname file. If there
16        # is, force the hostname to be that.
17        #
18    
19        try:
20            fh = open(os.path.join(FIG_Config.fig_disk, "config", "hostname"))
21            host = fh.readline()
22            return host.strip()
23        except:
24            pass
25    
26        #
27      # First check to see if we our hostname is correct.      # First check to see if we our hostname is correct.
28      #      #
29      # Map it to an IP address, and try to bind to that ip.      # Map it to an IP address, and try to bind to that ip.
# Line 22  Line 39 
39      # local binding test.      # local binding test.
40      #      #
41    
42      if not hostname.endswith(".local."):      if not re.search(r"\.local\.?$", hostname):
43    
44          #          #
45          # First check that hostname is a fqdn, and that we can bind to it.          # First check that hostname is a fqdn, and that we can bind to it.
# Line 236  Line 253 
253      new_url = urlparse.urlunparse(p)      new_url = urlparse.urlunparse(p)
254      return new_url      return new_url
255    
256    def get_seed_id():
257        #
258        # Retrieve the seed identifer from FIGdisk/config/seed_id.
259        #
260        # If it's not there, create one, and make it readonly.
261        #
262    
263        id_file = os.path.join(FIG_Config.fig_disk, "config", "seed_id")
264        if not os.path.isfile(id_file):
265    
266            fh = os.popen("uuidgen", "r")
267    
268            newid = fh.readline()
269            newid = newid.strip()
270    
271            fh.close()
272    
273            fh = open(id_file, "w")
274            print >>fh, newid
275            fh.close()
276    
277            os.chmod(id_file, 0444)
278    
279        fh = open(id_file)
280        id = fh.readline()
281        fh.close()
282        id = id.strip()
283        return id
284    
285  if __name__ == "__main__":  if __name__ == "__main__":
286    
287      print get_local_hostname()      print get_local_hostname()
288      print cgi_url()      print cgi_url()
289      print temp_url()      print temp_url()
290    
291        print get_seed_id()

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3