def controlLed(device, value): mapping = read() number = mapping[device] if value == 'on': turn_on_led(number) elif value == 'off': turn_off_led(number)
(options, args) = parser.parse_args() configfile='' if options.config==None: sys.stderr.write('ERROR: please give a configuration file (see -h)\n') sys.exit(-1) else: configfile=options.config if not os.path.isfile(configfile): sys.stderr.write('ERROR: can\'t open the file\n') sys.exit(-1) if not options.verbose: debug=True log(ok=True, msg="read configuration...") ENV = readConfig.read(configpath=configfile) #readConfig.printOut(ENV) repo=open_repo() for host in ENV.keys(): if host != C_GIT: log(ok=True, msg="work on host: %s"%host) if 'file' in ENV[host].keys(): get_copy(host) add2git(repo, "added config host %s"%host) if 'pc6428' in ENV[host].keys(): getPC6248(host) get_copy_remote(host) add2git(repo, "added pc6248 config from host %s"%host) if 'ap541' in ENV[host].keys():
conn.request("POST", self.get_url, self.paramsCMD, self.headersCMD) time.sleep(4) response = conn.getresponse() if response.status == 200: return True return False def __str__(self): return 'PC6428: host: '+self.host +"\n"+ \ "username: "******"\n"+ \ "file: " + self.server_file + "\n"+ \ "path: "+self.server_path if __name__ == '__main__': # this should be moved to test file ENV = readConfig.read(configpath='smc.conf.example') host = 'swicht01.mycompany.com' if 'ssh-server' in ENV.keys(): sshenv = ENV['ssh-server'] else: print "ERROR, no ssh-server config found" sys.exit(-1) if host in ENV.keys(): hostenv=ENV[host] else: print "ERROR, no host config found" sys.exit(-1) #print sshenv #print hostenv cl = PC6248(host, hostenv, sshenv)
return ( "AP541 : host: " + self.host + "\n" + "username: "******"\n" + "remotepath: " + self.remotepath + "\n" ) if __name__ == "__main__": # this should be moved to test file ENV = readConfig.read(configpath="smc.conf.example") # readConfig.printOut(ENV) host = "ap541.mycompany.com" if host in ENV.keys(): hostenv = ENV[host] else: print "ERROR, no host config found" sys.exit(-1) print hostenv cl = AP541(host, hostenv) print cl r, msg = cl.login() print r, msg if r == 200: r = cl.get_config()