Changeset 222

Show
Ignore:
Timestamp:
Tue Oct 10 01:34:57 2006
Author:
Brian
Message:

Change server to read ip and port numbers from a configuration file.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • server/trunk/update/server/ganttpv_update_server.py

    r221 r222  
    31 31 # 060824 - changed name format of backup files  
    32 32 # 060826 - publish service availability via zero config  
      33 # 061009 - Brian - use config file for ip, etc.  
    33 34  
    34 35 import SimpleXMLRPCServer  
     
    43 44 import socket  # only for the error handling  
    44 45 import Zeroconf  
      46 import ConfigParser  # to read the configuration file  
    45 47  
    46 48 debug = 3  
    47 49  
    48   # server location  
    49   server_name = "GanttPV Server"  # unique - use letters, digits, and spaces only  
    50                                   # if omitted, server will not publish via zero config  
    51   server_ip = "192.168.0.3"  # server location - change to actual address  
    52   # server_ip = "10.46.22.35"  # server location - change to actual address  
    53   server_port = 8001  
    54   # this key is required to add databases to server  
    55   server_key = "CE428F03"  # <-- change this key for each server  
    56    
    57 50 # directories  
    58 51 Path = os.path.abspath(sys.argv[0])  
     
    61 54 backup = os.path.join(Path, "backup")  # all backups  
    62 55  
      56 config_file = os.path.join(current, "Configuration.ini")  
      57 config = ConfigParser.SafeConfigParser()  
      58 config.readfp(open(config_file))  
      59  
      60 # zero config name  
      61 if config.has_option('network', 'server_name'):  
      62     server_name = config.get('network', 'server_name').rstrip()  
      63 else:  
      64     server_name = "GanttPV Server"  # unique - use letters, digits, and spaces only  
      65     # if omitted, server will not publish via zero config  
      66  
      67 # server location - must be a static ip address  
      68 if config.has_option('network', 'server_ip'):  
      69     server_ip = config.get('network', 'server_ip').rstrip()  
      70 else:  
      71     server_ip = "192.168.0.5"  # server location - change to reasonable default  
      72  
      73 # port number  
      74 if config.has_option('network', 'server_port'):  
      75     server_port = config.getint('network', 'server_port')  
      76 else:  
      77     server_port = 8001  
      78  
      79 # server key - this key is required to add databases to server  
      80 if config.has_option('network', 'server_key'):  
      81     server_key = config.get('network', 'server_key').rstrip()  
      82 else:  
      83     server_key = "CE428F03"  # <-- change this key for each server  
      84  
      85 print "\nClients need the following parameters to add files to this server:"  
      86 print "%s:%d,%s\n" % (server_ip, server_port, server_key)  
      87  
    63 88 SessionsFile = ""  
    64 89