本文整理汇总了Python中web.conflict函数的典型用法代码示例。如果您正苦于以下问题:Python conflict函数的具体用法?Python conflict怎么用?Python conflict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了conflict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _setReturnCode
def _setReturnCode(self, code):
"""Set the return code
:param: code
:type code: integer or string
returns success: [True|False]
"""
success = False
if code in (200, "200", "ok"):
web.ok()
success = True
elif code in (201, "201", "created"):
web.created()
success = True
elif code in (400, "400", "badrequest"):
web.badrequest()
elif code in (401, "401", "unauthorized"):
web.unauthorized()
elif code in (404, "404", "notfound"):
web.notfound()
elif code in (409, "409", "conflict"):
web.conflict()
elif code in (500, "500", "internalerror"):
web.internalerror()
if success:
logging.debug("[LayMan][_setReturnCode] Code: '%s'" % code)
else:
logging.error("[LayMan][_setReturnCode] Code: '%s'" % code)
return success
开发者ID:riskatlas,项目名称:layman,代码行数:32,代码来源:__init__.py
示例2: _PUT
def _PUT(self, *param, **params):
host_id = self.chk_hostby1(param)
if host_id is None: return web.notfound()
if not validates_host_edit(self):
self.logger.debug("Update Host OS is failed, Invalid input value.")
return web.badrequest(self.view.alert)
host = findbyhost1(self.orm, host_id)
cmp_host = findby1name(self.orm, self.input.m_name)
if cmp_host is not None and int(host_id) != cmp_host.id:
self.logger.debug("Update Host OS is failed, "
"Already exists name"
"- %s, %s" % (host, cmp_host))
return web.conflict(web.ctx.path)
hostname_check = findby1hostname(self.orm, self.input.m_hostname)
if hostname_check is not None and int(host_id) != hostname_check.id:
return web.conflict(web.ctx.path)
if is_param(self.input, "m_hostname"):
host.hostname = self.input.m_hostname
if is_param(self.input, "note_title"):
host.notebook.title = self.input.note_title
if is_param(self.input, "note_value"):
host.notebook.value = self.input.note_value
if is_param(self.input, "m_name"):
host.name = self.input.m_name
# Icon
icon_filename = None
if is_param(self.input, "icon_filename", empty=True):
host.icon = self.input.icon_filename
# tag UPDATE
if is_param(self.input, "tags"):
_tags = []
tag_array = comma_split(self.input.tags)
tag_array = uniq_sort(tag_array)
for x in tag_array:
if t_count(self.orm, x) == 0:
_tags.append(t_new(x))
else:
_tags.append(t_name(self.orm, x))
host.tags = _tags
host.modified_user = self.me
m_update(self.orm, host)
return web.seeother(web.ctx.path)
开发者ID:fkei,项目名称:karesansui,代码行数:52,代码来源:hostby1.py
示例3: _PUT
def _PUT(self, *param, **params):
tag_id = param[0]
if not validates_param_id(self, tag_id):
self.logger.debug("Failed to update tag. The value of parameter is invalid.")
return web.badrequest(self.view.alert)
if not validates_tag(self):
self.logger.debug("Failed to update tag. The value of input is invalid.")
return web.badrequest(self.view.alert)
tag = findby1(self.orm, tag_id)
if not tag:
self.logger.debug("Failed to update tag. No such tag - id=%s" % tag_id)
return web.notfound()
cmp_tag = findby1name(self.orm, self.input.name)
if not cmp_tag is None:
if cmp_tag.id != tag.id:
self.logger.debug("Failed to update tag. The same tag already exist - id='%s'" % (cmp_tag.id))
return web.conflict(web.ctx.path)
tag.name = self.input.name
update(self.orm, tag)
return web.seeother(web.ctx.path)
开发者ID:goura,项目名称:karesansui,代码行数:25,代码来源:tag.py
示例4: checked_data
def checked_data(self, validate_method=None, **kwargs):
try:
data = kwargs.pop('data', web.data())
if validate_method:
method = validate_method
else:
method = self.validator.validate
valid_data = method(data, **kwargs)
except (
errors.InvalidInterfacesInfo,
errors.InvalidMetadata
) as exc:
notifier.notify("error", str(exc))
raise web.badrequest(message=str(exc))
except (
errors.AlreadyExists
) as exc:
err = web.conflict()
err.message = exc.message
raise err
except (
errors.InvalidData,
Exception
) as exc:
raise web.badrequest(message=str(exc))
return valid_data
开发者ID:adanin,项目名称:fuel-web,代码行数:27,代码来源:base.py
示例5: _DELETE
def _DELETE(self, *param, **params):
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None: return web.notfound()
if is_int(param[2]) is False:
return web.notfound()
nic_id = int(param[2])
model = findbyguest1(self.orm, guest_id)
# virt
kvc = KaresansuiVirtConnection()
try:
domname = kvc.uuid_to_domname(model.uniq_key)
if not domname: return web.conflict(web.ctx.path)
virt = kvc.search_kvg_guests(domname)[0]
guest = MergeGuest(model, virt)
nic_info = virt.get_interface_info()[nic_id]
finally:
kvc.close()
mac = nic_info["mac"]["address"]
self.logger.debug('spinning off delete_nic_job dom=%s, mac=%s' % (domname, mac))
if delete_nic_job(self,model,domname,mac) is True:
return web.accepted()
else:
return False
开发者ID:AdUser,项目名称:karesansui,代码行数:28,代码来源:guestby1nicby1.py
示例6: _PUT
def _PUT(self, *param, **params):
user_id = param[0]
if not validates_param_id(self, user_id):
self.logger.debug("Failed to update account. the value of parameter is invalid.")
return web.notfound(self.view.alert)
if not validates_user(self):
self.logger.debug("Failed to update account. the value of input is invalid.")
return web.badrequest(self.view.alert)
user = findby1(self.orm, user_id)
if not user:
self.logger.debug("Failed to update account. No such account - id=%s" % user_id)
return web.notfound()
cmp_user = findby1email(self.orm, self.input.email)
if not cmp_user is None:
if int(user_id) != cmp_user.id:
self.logger.debug("Failed to update account. The same mail address '%s' already exist - user='%s'" % (self.input.email, cmp_user.nickname))
return web.conflict(web.ctx.path)
user.nickname = self.input.nickname
user.email = self.input.email
user.languages = self.input.languages
if not is_empty(self.input.new_password):
if compare_password(self, user) == False:
return web.badrequest(self.view.alert)
(password, salt) = sha1encrypt(self.input.new_password)
user.password = password
user.salt = salt
update(self.orm, user)
return web.seeother(web.ctx.path)
开发者ID:AdUser,项目名称:karesansui,代码行数:35,代码来源:userby1.py
示例7: _PUT
def _PUT(self, *param, **params):
host_id = self.chk_hostby1(param)
if host_id is None:
return web.notfound()
if not validates_server(self):
self.logger.debug("Update server setting failed. Did not validate.")
return web.badrequest(self.view.alert)
try:
conf = os.environ.get("KARESANSUI_CONF")
_K2V = K2V(conf)
config = _K2V.read()
tmp_unique_key = config["application.uniqkey"]
# make whether unique key is unique
uniq_key_check = findbyalluniquekey(self.orm, self.input.uniqkey)
if uniq_key_check != [] and config["application.uniqkey"] != self.input.uniqkey:
self.logger.debug("Update unique key failed, Already exists Unique key - %s" % uniq_key_check[0].id)
return web.conflict(web.ctx.path)
lighttpdconf_path = set_server_conf(config, self.input, self.orm)
_K2V.write(config)
except (IOError, KaresansuiGadgetException), kge:
self.logger.debug(kge)
raise KaresansuiGadgetException, kge
开发者ID:goura,项目名称:karesansui,代码行数:27,代码来源:hostby1settingby1general.py
示例8: _PUT
def _PUT(self, *param, **params):
"""<comment-ja>
Japanese Comment
</comment-ja>
<comment-en>
TODO: English Comment
</comment-en>
"""
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None:
return web.notfound()
if is_param(self.input, "memory"):
memory = int(self.input.memory)
else:
memory = None
max_memory = int(self.input.max_memory)
model = findbyguest1(self.orm, guest_id)
# virt
kvc = KaresansuiVirtConnection()
try:
domname = kvc.uuid_to_domname(model.uniq_key)
if not domname:
return web.conflict(web.ctx.path)
virt = kvc.search_kvg_guests(domname)[0]
info = virt.get_info()
# maxMem = info["maxMem"]
now_memory = info["memory"]
mem_info = kvc.get_mem_info()
nodeinfo = kvc.get_nodeinfo()
finally:
kvc.close()
# valid
# if (mem_info["host_free_mem"] + (now_memory / 1024)) < memory:
# return web.badrequest("Memory value is greater than the maximum memory value. - memory=%s" % self.input.memory)
options = {}
options["name"] = domname
options["maxmem"] = max_memory
if memory is None:
options["memory"] = max_memory
else:
options["memory"] = memory
_cmd = dict2command("%s/%s" % (karesansui.config["application.bin.dir"], VIRT_COMMAND_SET_MEMORY), options)
cmdname = "Set memory"
_jobgroup = JobGroup(cmdname, karesansui.sheconf["env.uniqkey"])
_jobgroup.jobs.append(Job("%s command" % cmdname, 0, _cmd))
_machine2jobgroup = m2j_new(
machine=model,
jobgroup_id=-1,
uniq_key=karesansui.sheconf["env.uniqkey"],
created_user=self.me,
modified_user=self.me,
)
save_job_collaboration(self.orm, self.pysilhouette.orm, _machine2jobgroup, _jobgroup)
return web.accepted(url=web.ctx.path)
开发者ID:goura,项目名称:karesansui,代码行数:59,代码来源:guestby1memory.py
示例9: PUT
def PUT(self, name):
if not re.match(r'', name):
raise web.conflict()
with Transaction(models.Srv4FileStats) as trans:
res = models.CatalogRelease.selectBy(name=name, connection=trans)
if res.count():
return cjson.encode('%s already exists' % name)
models.CatalogRelease(name=name, connection=trans)
return cjson.encode('%s has been created' % name)
开发者ID:dago,项目名称:opencsw,代码行数:9,代码来源:releases_web.py
示例10: _POST
def _POST(self, *param, **params):
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None: return web.notfound()
if not validates_snapshot(self):
return web.badrequest(self.view.alert)
guest = findbyguest1(self.orm, guest_id)
kvs = KaresansuiVirtSnapshot(readonly=False)
try:
domname = kvs.kvc.uuid_to_domname(guest.uniq_key)
if not domname: return web.conflict(web.ctx.path)
virt = kvs.kvc.search_kvg_guests(domname)[0]
if virt.is_active() is True:
return web.badrequest(_("Guest is running. Please stop and try again. name=%s" % domname))
finally:
kvs.finish()
id = int(time.time())
notebook = new_notebook(self.input.title, self.input.value)
snapshot = new_snapshot(guest, id, self.me, self.me, notebook)
save_snapshot(self.orm, snapshot)
options = {}
options['name'] = domname
options['id'] = id
_cmd = dict2command(
"%s/%s" % (karesansui.config['application.bin.dir'], VIRT_COMMAND_TAKE_SNAPSHOT),
options)
cmdname = 'Take Snapshot'
_jobgroup = JobGroup(cmdname, karesansui.sheconf['env.uniqkey'])
_jobgroup.jobs.append(Job('%s command' % cmdname, 0, _cmd))
_machine2jobgroup = m2j_new(machine=guest,
jobgroup_id=-1,
uniq_key=karesansui.sheconf['env.uniqkey'],
created_user=self.me,
modified_user=self.me,
)
save_job_collaboration(self.orm,
self.pysilhouette.orm,
_machine2jobgroup,
_jobgroup,
)
return web.accepted()
开发者ID:AdUser,项目名称:karesansui,代码行数:52,代码来源:guestby1snapshot.py
示例11: _POST
def _POST(self, *param, **params):
if not validates_icon(self):
self.logger.debug("Create Icon is failed, Invalid input value")
return web.badrequest(add_prefix(self.view.alert, "400"))
icon_filevalue = self.input.multi_icon.value
icon_filename = "%s.%s" % (uniq_filename(), imghdr.what(None, icon_filevalue))
if is_path(icon_filename) is True:
return web.badrequest("Not to include the path.")
icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename)
icon_webpath = ICON_DIR_TPL % (web.ctx.homepath, icon_filename)
if os.path.exists(icon_realpath):
web.conflict(icon_webpath, add_prefix("icon already exists", "409"))
try:
create_file(icon_realpath, icon_filevalue)
except IOError, ioe:
self.logger.error("Failed to write icon file. - filename=%s" % icon_filename)
return web.internalerror(add_prefix("Failed to create icon file.", "500"))
开发者ID:goura,项目名称:karesansui,代码行数:22,代码来源:icon.py
示例12: DELETE
def DELETE(self, name):
with Transaction(models.Srv4FileStats) as trans:
try:
o = models.CatalogRelease.selectBy(name=name, connection=trans).getOne()
except sqlobject.main.SQLObjectNotFound:
raise web.notfound()
res = models.Srv4FileInCatalog.select(models.Srv4FileInCatalog.q.catrel==o,
connection=trans)
if res.count():
# There still are packages in this catalog. We cannot remove it.
raise web.conflict()
o.destroySelf()
return cjson.encode('%s has been deleted' % name)
开发者ID:dago,项目名称:opencsw,代码行数:13,代码来源:releases_web.py
示例13: POST
def POST(self, device_name, from_state, to_state):
args, body = templeton.handlers.get_request_parms()
if 'pxe_config' in body:
pxe_config = body['pxe_config']
boot_config = body.get('boot_config', '')
else:
pxe_config = None
boot_config = None
success = mozpool.lifeguard.driver.conditional_state_change(
device_name, from_state, to_state, pxe_config, boot_config)
if not success:
raise web.conflict()
return {}
开发者ID:jhopkinsmoz,项目名称:mozpool,代码行数:13,代码来源:handlers.py
示例14: _POST
def _POST(self, *param, **params):
if not validates_tag(self):
self.logger.debug("Failed to create tag. The value of input is invalid.")
return web.badrequest(self.view.alert)
tag = findby1name(self.orm, self.input.name)
if tag:
self.logger.debug("Failed to create tag. The same tag already exist - id='%s'" % (tag.id))
return web.conflict(web.ctx.path)
new_tag = new(self.input.name)
save(self.orm, new_tag)
return web.created(None)
开发者ID:goura,项目名称:karesansui,代码行数:14,代码来源:tag.py
示例15: _PUT
def _PUT(self, *param, **params):
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None:
return web.notfound()
if is_int(param[2]) is False:
return web.notfound()
nic_id = int(param[2])
if not validates_nicby1(self):
return web.badrequest(self.view.alert)
model = findbyguest1(self.orm, guest_id)
# virt
kvc = KaresansuiVirtConnection()
try:
domname = kvc.uuid_to_domname(model.uniq_key)
if not domname:
return web.conflict(web.ctx.path)
virt = kvc.search_kvg_guests(domname)[0]
guest = MergeGuest(model, virt)
old_mac = virt.get_interface_info()[nic_id]["mac"]["address"]
nic_info = virt.get_interface_info()
finally:
kvc.close()
new_mac = self.input.mac_address
if old_mac != new_mac:
f_chk = True
for x in nic_info:
if x["mac"]["address"] == new_mac:
f_chk = False
break
if f_chk is False:
return web.badrequest(_("Specified MAC address is already defined."))
self.logger.debug(
"spinning off change_mac_job dom=%s, from_mac=%s, to_mac=%s" % (domname, old_mac, new_mac)
)
if change_mac_job(self, model, domname, old_mac, new_mac) is True:
return web.accepted(url=web.ctx.path)
else:
return False
else:
return web.accepted(url=web.ctx.path)
开发者ID:goura,项目名称:karesansui,代码行数:48,代码来源:guestby1nicby1.py
示例16: _POST
def _POST(self, *param, **params):
if not validates_user(self):
self.logger.debug("Failed to create account. the values of input are invalid.")
return web.badrequest(self.view.alert)
user = findby1email(self.orm, self.input.email)
if user:
self.logger.debug("Failed to create account. The same mail address '%s' already exist - user='%s'" % (self.input.email, user.nickname))
return web.conflict(web.ctx.path)
(password, salt) = sha1encrypt(self.input.new_password)
new_user = new(self.input.email,
password,
salt,
self.input.nickname,
self.input.languages
)
save(self.orm, new_user)
return web.created(None)
开发者ID:goura,项目名称:karesansui,代码行数:21,代码来源:user.py
示例17: _GET
def _GET(self, *param, **params):
"""<comment-ja>
virDomainState
- VIR_DOMAIN_NOSTATE = 0
- VIR_DOMAIN_RUNNING = 1
- VIR_DOMAIN_BLOCKED = 2
- VIR_DOMAIN_PAUSED = 3
- VIR_DOMAIN_SHUTDOWN = 4
- VIR_DOMAIN_SHUTOFF = 5
- VIR_DOMAIN_CRASHED = 6
</comment-ja>
<comment-en>
TODO: English Comment
</comment-en>
"""
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None: return web.notfound()
model = findbyguest1(self.orm, guest_id)
# virt
kvc = KaresansuiVirtConnection()
try:
domname = kvc.uuid_to_domname(model.uniq_key)
if not domname: return web.conflict(web.ctx.path)
virt = kvc.search_kvg_guests(domname)
if self.__template__["media"] == 'json':
self.view.status = json_dumps(virt[0].status())
else:
self.view.status = virt[0].status()
finally:
kvc.close()
#self.__template__.dir = 'guestby1'
return True
开发者ID:AdUser,项目名称:karesansui,代码行数:37,代码来源:guestby1status.py
示例18: checked_data
def checked_data(self, validate_method=None):
try:
if validate_method:
data = validate_method(web.data())
else:
data = self.validator.validate(web.data())
except (
errors.InvalidInterfacesInfo,
errors.InvalidMetadata
) as exc:
notifier.notify("error", str(exc))
raise web.badrequest(message=str(exc))
except (
errors.AlreadyExists
) as exc:
err = web.conflict()
err.message = exc.message
raise err
except (
errors.InvalidData,
Exception
) as exc:
raise web.badrequest(message=str(exc))
return data
开发者ID:mydaisy2,项目名称:fuelweb,代码行数:24,代码来源:base.py
示例19: _PUT
def _PUT(self, *param, **params):
if not validates_me(self):
return web.badrequest(self.view.alert)
if self.me.id != int(self.input.id):
self.logger.info("Update account is failed, "
"posted ID parameter is different from me ID "
"- posted ID %s, me ID %s" % (self.input.id, self.me.id))
return web.badrequest(_('ID is wrong. Your ID is not %s.') % self.input.id)
me = findby1(self.orm, self.input.id)
if not me:
self.logger.debug("Update account is failed, "
"Did not exist account - id=%s" % self.input.id)
return web.notfound()
cmp_user = findby1email(self.orm, self.input.email)
if not cmp_user is None:
if me.id != cmp_user.id:
self.logger.info("Update account is failed, "
"Already exists mail address "
"- %s, %s" % (me, cmp_user))
return web.conflict(web.ctx.path)
if self.input.password:
if compare_password(self, self.me) is False:
return web.badrequest(self.view.alert)
(password, salt) = sha1encrypt(self.input.new_password)
me.password = password
me.salt = salt
me.email = self.input.email
me.languages = self.input.languages
me.nickname = self.input.nickname
dba_update(self.orm, me)
self.me = me
return web.seeother(web.ctx.path)
开发者ID:AdUser,项目名称:karesansui,代码行数:36,代码来源:me.py
示例20: POST
def POST(self, device_name, from_state, to_state):
success = mozpool.lifeguard.driver.conditional_state_change(
device_name, from_state, to_state)
if not success:
raise web.conflict()
return {}
开发者ID:cnh,项目名称:mozpool,代码行数:6,代码来源:handlers.py
注:本文中的web.conflict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论