[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.1, Thu Feb 12 16:00:31 2004 UTC revision 1.6, Mon Mar 15 23:14:11 2004 UTC
# Line 13  Line 13 
13      #      #
14    
15      hostname = socket.getfqdn()      hostname = socket.getfqdn()
16      hostname = "yips"  
17        #
18        # See if hostname is something.local., which is what
19        # a Mac will return if it didn't get a name via some
20        # other mechanism (DHCP or static config). We have to
21        # check here because otherwise it will pass the fqdn and
22        # local binding test.
23        #
24    
25        if not re.search(r"\.local\.?$", hostname):
26    
27      #      #
28      # 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.
29      #      #
# Line 131  Line 141 
141      for l in fh:      for l in fh:
142          cols = l.strip().split()          cols = l.strip().split()
143    
144          if cols[0] == "default" or cols[0] == "0.0.0.0":          if len(cols) > 0 and (cols[0] == "default" or cols[0] == "0.0.0.0"):
145              interface_name = cols[-1]              interface_name = cols[-1]
146              break              break
147    
148      fh.close()      fh.close()
149    
150      print "Default route on ", interface_name      # print "Default route on ", interface_name
151    
152      #      #
153      # Find ifconfig.      # Find ifconfig.
# Line 157  Line 167 
167          print >> sys.stderr, "Ifconfig not found"          print >> sys.stderr, "Ifconfig not found"
168          return "localhost"          return "localhost"
169    
170      print >> sys.stderr, "found ifconfig ", ifconfig      # print >> sys.stderr, "found ifconfig ", ifconfig
171    
172      try:      try:
173          fh = os.popen(ifconfig+ " " + interface_name, "r")          fh = os.popen(ifconfig+ " " + interface_name, "r")
# Line 226  Line 236 
236      new_url = urlparse.urlunparse(p)      new_url = urlparse.urlunparse(p)
237      return new_url      return new_url
238    
239    def get_seed_id():
240        #
241        # Retrieve the seed identifer from FIGdisk/config/seed_id.
242        #
243        # If it's not there, create one, and make it readonly.
244        #
245    
246        id_file = os.path.join(FIG_Config.fig_disk, "config", "seed_id")
247        if not os.path.isfile(id_file):
248    
249            fh = os.popen("uuidgen", "r")
250    
251            newid = fh.readline()
252            newid = newid.strip()
253    
254            fh.close()
255    
256            fh = open(id_file, "w")
257            print >>fh, newid
258            fh.close()
259    
260            os.chmod(id_file, 0444)
261    
262        fh = open(id_file)
263        id = fh.readline()
264        fh.close()
265        id = id.strip()
266        return id
267    
268  if __name__ == "__main__":  if __name__ == "__main__":
269    
270      print get_local_hostname()      print get_local_hostname()
271      print cgi_url()      print cgi_url()
272      print temp_url()      print temp_url()
273    
274        print get_seed_id()

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3