本文整理汇总了Python中show_message.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_all
def check_all(self):
""" Check that all requirements are meet """
path = "/var/tmp/.cnchi_partitioning_completed"
if os.path.exists(path):
show.error(_("You must reboot before retrying again."))
return False
has_internet = misc.has_connection()
self.prepare_network_connection.set_state(has_internet)
on_power = not self.on_battery()
self.prepare_power_source.set_state(on_power)
space = self.has_enough_space()
self.prepare_enough_space.set_state(space)
if has_internet:
updated = self.is_updated()
else:
updated = False
self.updated.set_state(updated)
if self.checks_are_optional:
return True
if has_internet and space:
return True
return False
开发者ID:satriani-vai,项目名称:Cnchi,代码行数:30,代码来源:check.py
示例2: download
def download(self, name, md5):
url = _url_prefix + name
response = ""
try:
request = urlopen(url)
txt = request.read()
#.decode('utf-8')
except urllib.error.HTTPError as e:
logging.exception('Unable to get %s - HTTPError = %s' % (name, e.reason))
return False
except urllib.error.URLError as e:
logging.exception('Unable to get %s - URLError = %s' % (name, e.reason))
return False
except httplib.error.HTTPException as e:
logging.exception('Unable to get %s - HTTPException' % name)
return False
except Exception as e:
import traceback
logging.exception('Unable to get %s - Exception = %s' % (name, traceback.format_exc()))
return False
web_md5 = self.get_md5(txt)
if web_md5 != md5:
txt = "Checksum error in %s. Download aborted" % name
logging.error(txt)
show.error(txt)
return False
new_name = os.path.join(_base_dir, name + "." + self.web_version.replace(".", "_"))
with open(new_name, "wb") as f:
f.write(txt)
return True
开发者ID:arquetype,项目名称:thus,代码行数:35,代码来源:updater.py
示例3: do_activate
def do_activate(self):
""" Override the 'activate' signal of GLib.Application. """
try:
import main_window
except ImportError as err:
msg = "Cannot create DSGos_Installer main window: {0}".format(err)
logging.error(msg)
sys.exit(1)
# Check if we have administrative privileges
if os.getuid() != 0:
msg = _("This installer must be run with administrative privileges, " "and cannot continue without them.")
show.error(None, msg)
return
# Check if we're already running
if self.already_running():
msg = _(
"You cannot run two instances of this installer.\n\n"
"If you are sure that the installer is not already running\n"
"you can run this installer using the --force option\n"
"or you can manually delete the offending file.\n\n"
"Offending file: '{0}'"
).format(self.TMP_RUNNING)
show.error(None, msg)
return
window = main_window.MainWindow(self, cmd_line)
self.add_window(window)
window.show()
with open(self.TMP_RUNNING, "w") as tmp_file:
tmp_file.write("DSGos_Installer {0}\n{1}\n".format(info.DSGos_Installer_VERSION, os.getpid()))
开发者ID:KGkotzamanidis,项目名称:DSGos-Installer,代码行数:33,代码来源:DSGos_Installer.py
示例4: fill_choose_partition_combo
def fill_choose_partition_combo(self):
self.choose_partition_combo.remove_all()
devices = []
for device in sorted(self.oses.keys()):
# if "Swap" not in self.oses[device]:
if "windows" in self.oses[device].lower():
devices.append(device)
if len(devices) > 1:
new_device_found = False
for device in sorted(devices):
if self.get_new_device(device):
new_device_found = True
line = "{0} ({1})".format(self.oses[device], device)
self.choose_partition_combo.append_text(line)
self.select_first_combobox_item(self.choose_partition_combo)
self.show_all()
if not new_device_found:
txt = _("Can't find any spare partition number.\nAlongside installation can't continue.")
self.choose_partition_label.hide()
self.choose_partition_combo.hide()
self.label.set_markup(txt)
show.error(self.get_toplevel(), txt)
elif len(devices) == 1:
self.set_resize_widget(devices[0])
self.show_all()
self.choose_partition_label.hide()
self.choose_partition_combo.hide()
else:
logging.warning(_("Can't find any installed OS!"))
开发者ID:Gyruman,项目名称:thus,代码行数:32,代码来源:alongside.py
示例5: create_partition
def create_partition(diskob, part_type, geom):
# A lot of this is similar to Anaconda, but customized to fit our needs
nstart = geom.start
nend = geom.end
if nstart < 2048:
nstart = 2048
# Just in case you try to create partition larger than disk.
# This case should be caught in the frontend!
# Never let user specify a length exceeding the free space.
if nend > diskob.device.length - 1:
nend = diskob.device.length - 1
nalign = diskob.partitionAlignment
if not nalign.isAligned(geom, nstart):
nstart = nalign.alignNearest(geom, nstart)
if not nalign.isAligned(geom, nend):
nend = nalign.alignDown(geom, nend)
if part_type == 1:
nstart = nstart + nalign.grainSize
mingeom = parted.Geometry(device=diskob.device, start=nstart, end=nend - 1)
maxgeom = parted.Geometry(device=diskob.device, start=nstart, end=nend)
if diskob.maxPartitionLength < maxgeom.length:
txt = _("Partition is too large!")
logging.error(txt)
show.error(None, txt)
return None
else:
npartition = parted.Partition(disk=diskob, type=part_type, geometry=maxgeom)
nconstraint = parted.Constraint(minGeom=mingeom, maxGeom=maxgeom)
diskob.addPartition(partition=npartition, constraint=nconstraint)
return npartition
开发者ID:codyzu,项目名称:Cnchi,代码行数:30,代码来源:partition_module.py
示例6: start_installation
def start_installation(self):
# Alongside method shrinks selected partition
# and creates root and swap partition in the available space
if self.is_room_available() is False:
return
partition_path = self.row[0]
otherOS = self.row[1]
fs_type = self.row[2]
# what if path is sda10 (two digits) ? this is wrong
device_path = self.row[0][:-1]
#re.search(r'\d+$', self.row[0])
new_size = self.new_size
# first, shrink filesystem
res = fs.resize(partition_path, fs_type, new_size)
if res:
# destroy original partition and create a new resized one
pm.split_partition(device_path, partition_path, new_size)
else:
txt = _("Can't shrink %s(%s) filesystem") % (otherOS, fs_type)
logging.error(txt)
show.error(txt)
return
'''
开发者ID:prodigeni,项目名称:thus,代码行数:30,代码来源:alongside.py
示例7: delete_partition
def delete_partition(diskob, part):
try:
diskob.deletePartition(part)
except Exception as general_error:
txt = _("Can't delete partition {0}").format(part)
logging.error(txt)
logging.error(general_error)
debug_txt = "{0}\n{1}".format(txt, general_error)
show.error(None, debug_txt)
开发者ID:codyzu,项目名称:Cnchi,代码行数:9,代码来源:partition_module.py
示例8: delete_partition
def delete_partition(diskob, part):
try:
diskob.deletePartition(part)
except Exception as err:
txt = _("Can't delete partition %s") % part
logging.error(txt)
logging.error(err)
debugtxt = ("%s\n%s" % (txt, err))
show.error(debugtxt)
开发者ID:prodigeni,项目名称:thus,代码行数:9,代码来源:partition_module.py
示例9: delete_partition
def delete_partition(diskob, part):
""" Remove partition from disk object """
try:
diskob.deletePartition(part)
except Exception as ex:
template = "Cannot delete partition {1}. An exception of type {1} occured. Arguments:\n{2!r}"
message = template.format(part, type(ex).__name__, ex.args)
logging.error(message)
show.error(None, message)
开发者ID:Antergos,项目名称:Cnchi,代码行数:9,代码来源:partition_module.py
示例10: remove_logical_volume
def remove_logical_volume(logical_volume):
""" Removes a logical volume """
try:
subprocess.check_call(["lvremove", "-f", logical_volume])
except subprocess.CalledProcessError as err:
txt = _("Can't remove logical volume {0}").format(logical_volume)
logging.error(txt)
logging.error(err)
debugtxt = "{0}\n{1}".format(txt, err)
show.error(None, debugtxt)
开发者ID:Gyruman,项目名称:thus,代码行数:10,代码来源:lvm.py
示例11: remove_physical_volume
def remove_physical_volume(physical_volume):
""" Removes a physical volume """
try:
subprocess.check_call(["pvremove", "-f", physical_volume])
except subprocess.CalledProcessError as err:
txt = _("Can't remove physical volume %s") % physical_volume
logging.error(txt)
logging.error(err)
debugtxt = ("%s\n%s" % (txt, err))
show.error(debugtxt)
开发者ID:Acidburn0zzz,项目名称:thus,代码行数:10,代码来源:lvm.py
示例12: get_devices
def get_devices():
""" Get all devices """
device_list = parted.getAllDevices()
disk_dic = {}
myhomepath = '/run/archiso/bootmnt'
if os.path.exists(myhomepath):
myhome = subprocess.check_output(["df", "-P", myhomepath]).decode()
else:
myhome = ""
for dev in device_list:
if dev.path in myhome:
continue
# I left all of the below here but commented out to see some use cases
# isbusy = in use/mounted. Needs to flag if 'yes' to prompt user to umount
# isbusy = dev.busy
# path gives /dev/sda or something similar
# myname = dev.path
# Hard drives measure themselves assuming kilo=1000, mega=1mil, etc
# limiter = 1000
# Some disk size calculations
# byte_size = dev.length * dev.sectorSize
# megabyte_size = byte_size / (limiter * limiter)
# gigabyte_size = megabyte_size / limiter
# print(byte_size)
# print(dev.length)
# Must create disk object to drill down
# Skip cd drive, special devices like LUKS and LVM and
# RPMB (Replay Protected Memory Block)
disk_obj = None
rpmb = (dev.path.startswith("/dev/mmcblk") and dev.path.endswith("rpmb"))
exclude = (dev.path.startswith("/dev/sr") or dev.path.startswith("/dev/mapper"))
if not rpmb and not exclude:
try:
disk_obj = parted.Disk(dev)
result = OK
except parted.DiskLabelException:
# logging.warning('Unrecognised disk label in device %s.', dev.path)
result = UNRECOGNISED_DISK_LABEL
except Exception as ex:
template = "Cannot get devices information. An exception of type {0} occured. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
logging.error(message)
show.error(None, message)
result = UNKNOWN_ERROR
finally:
disk_dic[dev.path] = (disk_obj, result)
return disk_dic
开发者ID:Antergos,项目名称:Cnchi,代码行数:52,代码来源:partition_module.py
示例13: get_devices
def get_devices():
device_list = parted.getAllDevices()
disk_dic = {}
myhomepath = '/bootmnt'
if os.path.exists(myhomepath):
myhome = subprocess.check_output(["df", "-P", myhomepath]).decode()
else:
myhome = ""
for dev in device_list:
if dev.path in myhome:
continue
# I left all of the below here but commented out to see some use cases
# isbusy = in use/mounted. Needs to flag if 'yes' to prompt user to umount
# isbusy = dev.busy
# path gives /dev/sda or something similar
# myname = dev.path
# Hard drives measure themselves assuming kilo=1000, mega=1mil, etc
# limiter = 1000
# Some disk size calculations
# byte_size = dev.length * dev.sectorSize
# megabyte_size = byte_size / (limiter * limiter)
# gigabyte_size = megabyte_size / limiter
# print(byte_size)
# print(dev.length)
# Must create disk object to drill down
# Skip all blacklisted devices
dev_name = dev.path[5:]
if any(re.search(expr, dev_name) for expr in DEVICE_BLACKLIST):
continue
# Skip cd drive and special devices like LUKS and LVM
disk_obj = None
if not dev.path.startswith("/dev/sr") and not dev.path.startswith("/dev/mapper"):
try:
disk_obj = parted.Disk(dev)
result = OK
except parted.DiskLabelException:
# logging.warning(_('Unrecognised disk label in device {0}.'.format(dev.path)))
result = UNRECOGNISED_DISK_LABEL
except Exception as general_error:
logging.error(general_error)
msg = _("Exception: {0}.\nFor more information take a look at /tmp/thus.log").format(general_error)
show.error(None, msg)
result = UNKNOWN_ERROR
finally:
disk_dic[dev.path] = (disk_obj, result)
return disk_dic
开发者ID:Gyruman,项目名称:thus,代码行数:52,代码来源:partition_module.py
示例14: get_used_space_from_path
def get_used_space_from_path(path):
try:
result = subprocess.check_output(shlex.split('df -H %s' % path)).decode()
lines = result.split('\n')
used_space = lines[1].split()[2]
except subprocess.CalledProcessError as err:
used_space = 0
txt = _("Can't detect used space from %s") % path
logging.error(txt)
logging.error(err)
debugtxt = ("%s\n%s" % (txt, err))
show.error(debugtxt)
return used_space
开发者ID:prodigeni,项目名称:thus,代码行数:14,代码来源:partition_module.py
示例15: get_used_space_from_path
def get_used_space_from_path(path):
try:
cmd = ["df", "-H", path]
result = subprocess.check_output(cmd).decode()
lines = result.split("\n")
used_space = lines[1].split()[2]
except subprocess.CalledProcessError as process_error:
used_space = 0
txt = _("Can't detect used space from {0}: {1}").format(path, process_error)
logging.error(txt)
debug_txt = "{0}\n{1}".format(txt, process_error)
show.error(None, debug_txt)
return used_space
开发者ID:codyzu,项目名称:Cnchi,代码行数:14,代码来源:partition_module.py
示例16: combobox_changed
def combobox_changed(self, combobox, name):
tree_iter = combobox.get_active_iter()
d = {'root':'swap', 'swap':'root'}
op = d[name]
if tree_iter != None:
self.device[name] = combobox.get_active_text()
log.debug(self.device[name])
if self.device[op] != "":
if self.device[op] == self.device[name]:
show.error(_("You can't select the same device for both mount points!"))
self.forward_button.set_sensitive(False)
else:
self.forward_button.set_sensitive(True)
开发者ID:prodigeni,项目名称:Cnchi,代码行数:15,代码来源:installation_easy.py
示例17: remove_volume_group
def remove_volume_group(volume_group):
""" Removes an entire volume group """
# Before removing the volume group, remove its logical volumes
logical_volumes = get_logical_volumes(volume_group)
for logical_volume in logical_volumes:
remove_logical_volume(logical_volume)
# Now, remove the volume group
try:
subprocess.check_call(["vgremove", "-f", volume_group])
except subprocess.CalledProcessError as err:
txt = _("Can't remove volume group %s") % volume_group
logging.error(txt)
logging.error(err)
debugtxt = ("%s\n%s" % (txt, err))
show.error(debugtxt)
开发者ID:Acidburn0zzz,项目名称:thus,代码行数:16,代码来源:lvm.py
示例18: remove_volume_group
def remove_volume_group(volume_group):
""" Removes an entire volume group """
# Before removing the volume group, remove its logical volumes
logical_volumes = get_logical_volumes(volume_group)
for logical_volume in logical_volumes:
remove_logical_volume(logical_volume)
# Now, remove the volume group
try:
subprocess.check_call(["vgremove", "-f", volume_group])
except subprocess.CalledProcessError as err:
txt = _("Can't remove volume group {0}").format(volume_group)
logging.error(txt)
logging.error(err)
debugtxt = "{0}\n{1}".format(txt, err)
show.error(None, debugtxt)
开发者ID:Gyruman,项目名称:thus,代码行数:16,代码来源:lvm.py
示例19: get_devices
def get_devices():
device_list = parted.getAllDevices()
disk_dic = {}
myhomepath = "/bootmnt"
if os.path.exists(myhomepath):
myhome = subprocess.check_output(["df", "-P", myhomepath]).decode()
else:
myhome = ""
for dev in device_list:
if dev.path in myhome:
continue
# I left all of the below here but commented out to see some use cases
# isbusy = in use/mounted. Needs to flag if 'yes' to prompt user to umount
# isbusy = dev.busy
# path gives /dev/sda or something similar
# myname = dev.path
# Hard drives measure themselves assuming kilo=1000, mega=1mil, etc
# limiter = 1000
# Some disk size calculations
# byte_size = dev.length * dev.sectorSize
# megabyte_size = byte_size / (limiter * limiter)
# gigabyte_size = megabyte_size / limiter
# print(byte_size)
# print(dev.length)
# Must create disk object to drill down
# Skip cd drive and special devices like LUKS and LVM
if not dev.path.startswith("/dev/sr") and not dev.path.startswith("/dev/mapper"):
try:
diskob = parted.Disk(dev)
result = OK
logging.info(_("Adding %s to disk_dic") % dev.path)
except parted.DiskLabelException as err:
logging.warning(_("Unrecognised disk label in device %s.") % dev.path)
diskob = None
result = UNRECOGNISED_DISK_LABEL
except Exception as err:
show.error((_("Exception: %s.\nFor more information take a look at /tmp/thus.log") % err))
diskob = None
result = UNKNOWN_ERROR
finally:
disk_dic[dev.path] = (diskob, result)
return disk_dic
开发者ID:netrunner-rolling,项目名称:thus,代码行数:46,代码来源:partition_module.py
示例20: on_treeview_cursor_changed
def on_treeview_cursor_changed(self, widget):
selection = self.treeview.get_selection()
if not selection:
return
model, tree_iter = selection.get_selected()
if tree_iter is None:
return
self.row = model[tree_iter]
partition_path = self.row[0]
other_os_name = self.row[1]
self.min_size = 0
self.max_size = 0
self.new_size = 0
try:
subprocess.call(["mount", partition_path, "/mnt"], stderr=subprocess.DEVNULL)
x = subprocess.check_output(['df', partition_path]).decode()
subprocess.call(["umount", "-l", "/mnt"], stderr=subprocess.DEVNULL)
x = x.split('\n')
x = x[1].split()
self.max_size = int(x[1]) / 1000
self.min_size = int(x[2]) / 1000
except subprocess.CalledProcessError as e:
txt = "CalledProcessError.output = %s" % e.output
logging.error(txt)
show.fatal_error(txt)
if self.min_size + MIN_ROOT_SIZE < self.max_size:
self.new_size = self.ask_shrink_size(other_os_name)
else:
txt = _("Can't shrink the partition (maybe it's nearly full?)")
logging.error(txt)
show.error(txt)
return
if self.new_size > 0 and self.is_room_available():
self.forward_button.set_sensitive(True)
else:
self.forward_button.set_sensitive(False)
开发者ID:Acidburn0zzz,项目名称:thus,代码行数:45,代码来源:alongside.py
注:本文中的show_message.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论