mysql.execute(dbopt, query, data) def arrayToHash(ary): ret = {} for i in ary: id = i[0] new_ary = i[1:] ret[id] = new_ary return ret parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="Read configuration from FILE", metavar="FILE") (options, args) = parser.parse_args() p = cfg.parse(options.filename) print p data = {} data["source"] = arrayToHash(fetch(p["source"])) data["dest"] = [] for dbopt in p["dest"]: data["dest"].append(arrayToHash(fetch(dbopt))) index = 0 for dest in data["dest"]: update = [] insert = [] for i in data["source"].keys(): if i in dest.keys():
return cls([Stage.from_dict(s) for s in d]) @classmethod def from_json(cls, j): d = json.loads(j) return cls.from_dict(d) ksppath = os.environ.get('KSPPATH') known_props = {} if ksppath is not None: try: with open( os.path.join(ksppath, 'GameData', 'ModuleManager.ConfigCache'), 'r') as f: d = cfg.parse(f) d = d.get('UrlConfig', {}) for c in d: if 'RESOURCE_DEFINITION' in c: r = c['RESOURCE_DEFINITION'] for rd in r: if 'name' in rd and 'density' in rd: known_props[rd['name']] = float(rd['density']) except IOError: pass if __name__ == '__main__': import sys j = sys.stdin.read() b = Booster.from_json(j) print "Wet mass: %.3ft" % (b.wet, )
queue=function['queue'], routing_key=function.get('routing_key'), host=rabbit_cfg.get('host'), port=rabbit_cfg.get('port'), userid=rabbit_cfg.get('userid'), password=rabbit_cfg.get('password'), durable=rabbit_cfg.get('durable', True) ) r.connect() r.declare() r.consume() if __name__ == '__main__': configuration = parse() rabbit_cfg = configuration['rabbitmq'] functions = configuration['functions'] processes = {} for function in functions: p = Process(target=worker, args=(rabbit_cfg, function)) p.start() processes[function['function_name']] = p while True: for p_name, process in processes.items(): if not process.is_alive(): for n, p in processes.items(): p.terminate() raise ValueError('%s crashed. Stopping rabbit_binder.' % p_name)
self.stage() return dv @classmethod def from_dict(cls, d): return cls([Stage.from_dict(s) for s in d]) @classmethod def from_json(cls, j): d = json.loads(j) return cls.from_dict(d) ksppath = os.environ.get('KSPPATH') known_props = {} if ksppath is not None: try: with open(os.path.join(ksppath, 'GameData', 'ModuleManager.ConfigCache'), 'r') as f: d = cfg.parse(f) d = d.get('UrlConfig', {}) for c in d: if 'RESOURCE_DEFINITION' in c: r = c['RESOURCE_DEFINITION'] for rd in r: if 'name' in rd and 'density' in rd: known_props[rd['name']] = float(rd['density']) except IOError: pass if __name__ == '__main__': import sys j = sys.stdin.read() b = Booster.from_json(j) print "Wet mass: %.3ft"%(b.wet,)
def parse_string(string): iter = iter_terminals_from_str(string) return cfg.parse(VNSSymbols, _action_table, iter)
#!/usr/bin/python # encoding: utf-8 from math import radians import cfg with open('rssk.cfg') as f: kop = cfg.parse(f) kc = kop['@Kopernicus[Kerbol?System]:FOR[RealSolarSystem]'][0] print "double epoch = %g;"%(float(kc['Epoch']),) bodies = kc['Body'] sun = [b for b in bodies if b['name'] == 'Sun'][0] sungp = float(sun['Properties'][0]['gravParameter']) print "double sungp = %g; // GM aka µ"%(sungp,) planets = [b for b in bodies if b.get('Orbit', [{}])[0].get('referenceBody') == 'Sun'] print """struct planet { \tconst char *name; \tdouble sma; \tdouble ecc; \tdouble inc; \tdouble lan; \tdouble ape; \tdouble mar; \tdouble gp; // GM aka µ \tdouble r; // surface radius
# -*- coding: utf-8 -*- ''' LICENSE GNU made by vk.com/myafk email: [email protected] http://python.su/forum/viewtopic.php?id=13059 ''' import urllib, urllib2, cookielib, re, json, cfg app_id = 2681884 # Desktop приложение useragent = 'Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.10.229 Version/11.60' settings = cfg.parse() def login(login, password, use_ini = True) : # Получение Cookies remixsid url_login = '******' login_ini = 1 if use_ini == True : account_settings = {} if settings.has_key(login) == True : account_settings = settings[login] if account_settings.has_key('sid') == True : login_ini = 0 sid = account_settings['sid'] try: if login_ini == 0 and use_ini == True: if check_sid(sid) == True: