コード例 #1
0
def assets_update():
    pa = request.form.get
    sn = pa('sn')
    ip = pa('ip')
    hostname = pa('hostname')
    os = pa('os')
    purchase_date = pa('purchase_date')
    warranty = pa('warranty')
    vendor = pa('vendor')
    model = pa('model')
    idc_id = pa('idc')
    admin = pa('admin')
    business = pa('business')
    cpu = pa('cpu')
    mem = pa('mem')
    disk = pa('disk')
    _is_ok, _error = assets.validate_update(ip, hostname, os, purchase_date,
                                            warranty, vendor, model, idc_id,
                                            admin, business, cpu, mem, disk)
    if _is_ok:
        assets.update(ip, hostname, os, purchase_date, warranty, vendor, model,
                      idc_id, admin, business, cpu, mem, disk, sn)
        return json.dumps({'is_ok': '修改成功'})
    else:
        return json.dumps({'error': "\n".join(_error['error'])})
コード例 #2
0
ファイル: views.py プロジェクト: ryan2333/reboot
def assets_update():
    pa = request.form.get
    sn = pa('sn')
    ip = pa('ip')
    hostname = pa('hostname')
    os = pa('os')
    purchase_date = pa('purchase_date')
    warranty = pa('warranty')
    vendor = pa('vendor')
    model = pa('model')
    idc_id = pa('idc')
    admin = pa('admin')
    business = pa('business')
    application = pa('application')
    cpu = pa('cpu')
    mem = pa('mem')
    disk = pa('disk')
    _is_ok, _error = assets.validate_update(ip, hostname, os, purchase_date, warranty, vendor, model, idc_id, admin, application,business, cpu, mem,
                      disk)
    if _is_ok:
        assets.update(ip, hostname, os, purchase_date, warranty, vendor, model, idc_id, admin, application,business, cpu, mem,
                      disk, sn)
        return json.dumps({'is_ok': '修改成功','success':'资产修改成功'})
    else:
        return json.dumps({'error': "\n".join(_error['error'])})
コード例 #3
0
def modify_asset():
    params = request.args if request.method == 'GET' else request.form
    ram = params.get('ram')
    cpu = params.get('cpu')
    disk = params.get('disk')
    admin = params.get('admin')
    ip = params.get('ip')
    sn = params.get('sn')
    import assets
    if assets.validate_update(ip):
        if assets.update(sn, ip, cpu, ram, disk, admin):
            return json.dumps({'_is_ok': 1, 'msg': '修改成功'})
        else:
            return json.dumps({'_is_ok': 0, 'msg': '数据录入失败,请检查资产唯一性!'})
    else:
        return json.dumps({'_is_ok': 0, 'msg': error})
コード例 #4
0
ファイル: elite.py プロジェクト: terix2k12/elitemo
            instructions.append((target, cf, q, r))
            z += r
            e += (q * r)
        profits.append((e, instructions))
        if not len(dealsFrom):
            instructions.append((target, 0, 0, 0))

    profits.sort(key=lambda (profit, instructions): profit, reverse=True)
    return profits[0]


if __name__ == "__main__":
    print "Start Elite:Dangerous Mission Optimizer"

    if len(sys.argv) == 1 and sys.argv[1] == "--update":
        assets.update("res/commodities.json", True)
        assets.update("res/stations.json")
        assets.update("res/systems_populated.json")
        assets.update("res/listings.csv")

    if len(sys.argv) == 1 or sys.argv[1] != "--maxi":
        print "Limited Edition"
        entities.systems = assets.unPickle("res/systems-mini-50.pic")
        entities.stations = assets.unPickle("res/stations-mini-50.pic")
        entities.markets = assets.unPickle("res/markets-mini-50.pic")
    else:
        entities.stations = assets.stations("stations.json")
        entities.systems = assets.systems("systems_populated.json")
        entities.markets = assets.markets("listings.csv")

    entities.commodities = assets.commodities("res/commodities.json")
コード例 #5
0
	def slow_test_asset_install(self):
		assets.update("res/commodities.json", True)
		assets.update("res/stations.json", True)
		assets.update("res/systems_populated.json", True)
		assets.update("res/listings.csv", True)
コード例 #6
0
	def slow_test_asset_update_fail(self):
		filename = "xzynono"
		success = assets.update(filename)
		exists = os.path.isfile(filename)
		self.assertEqual(not (success and exists), False)		
コード例 #7
0
	def slow_test_asset_update(self):
		filename = "commodities.json"
		success = assets.update(filename)
		exists = os.path.isfile(filename)
		self.assertEqual(success and exists, True)