本文整理汇总了Python中dialog.Dialog.gauge_stop方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.gauge_stop方法的具体用法?Python Dialog.gauge_stop怎么用?Python Dialog.gauge_stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.gauge_stop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Command
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import gauge_stop [as 别名]
class Command(BaseCommand):
help = "Import subjects from xls file"
args = 'filename'
def handle(self, *args, **options):
source_filename = args[0]
doc = xlrd.open_workbook(source_filename, formatting_info=True)
format_doc = SubjectFormat(doc)
from dialog import Dialog
self.dialog = Dialog()
if format_doc.sheet.ncols >= len(format_doc.cells):
logic = SubjectImportLogic(format_doc)
total = logic.doc.sheet.nrows - logic.doc.start_line
index = 0
self.dialog.gauge_start()
for index, parsed_row in enumerate(logic.doc):
logic.process_row(index, parsed_row)
try:
text=(u'Импорт: %s' % parsed_row[0][0]).encode('utf-8')
except IndexError:
text = (u'Ошибка').encode('utf-8')
self.dialog.gauge_update(int(float(index)/total*100),
text=text,
update_text=True)
self.dialog.gauge_stop()
num_errors = len(logic.errors)
self.dialog.infobox(u'Ошибок %d из %d: ' % (num_errors, total))
示例2: Command
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import gauge_stop [as 别名]
class Command(BaseCommand):
help = "Normalizes names"
def handle(self, *args, **options):
morph = get_morph(join(settings.PROJECT_DIR, 'morph'))
self.dialog = Dialog()
listeners = Listener.objects.filter(first_name__exact=u'')
total = listeners.count()
index = 0
self.dialog.gauge_start()
for listener in listeners:
listener.normalize_name(morph)
text = u'Склонение: %s %s %s' % (listener.last_name, listener.first_name, listener.patronymic)
self.dialog.gauge_update(int(float(index)/total*100),
text=text.encode('utf-8'),
update_text=True)
index += 1
self.dialog.gauge_stop()
示例3: Command
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import gauge_stop [as 别名]
class Command(BaseCommand):
help = "Import data from xls file"
args = 'filename'
def handle(self, *args, **options):
source_filename = args[0]
source_file = open(source_filename, 'r')
descriptor, name = tempfile.mkstemp()
os.fdopen(descriptor, 'wb').write(source_file.read())
doc = xlrd.open_workbook(name, formatting_info=True)
format_doc = ListenerFileFormat(doc)
from dialog import Dialog
self.dialog = Dialog()
if format_doc.sheet.ncols >= len(format_doc.cells):
logic = ListenerImportLogic(format_doc)
total = logic.doc.sheet.nrows - logic.doc.start_line
self.dialog.gauge_start()
for index, parsed_row in enumerate(logic.doc):
logic.process_row(index, parsed_row)
try:
text=(u'Импорт: %s' % ' '.join(parsed_row[5])).encode('utf-8')
except IndexError:
text = (u'Ошибка').encode('utf-8')
self.dialog.gauge_update(int(float(index)/total*100),
text=text,
update_text=True)
self.dialog.gauge_stop()
num_errors = len(logic.errors)
self.dialog.infobox(u'Ошибок %d из %d: ' % (num_errors, total))
next_cmd = NormalizeCommand()
next_cmd.handle()
示例4: WindowsInstallApp
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import gauge_stop [as 别名]
#.........这里部分代码省略.........
if code == self.d.OK: self.image_index = tag
else: raise FailedInstallStep
self.main_menu.advance()
def install_os(self):
if not self.system_part:
self.auto_prepare()
self.main_menu.position -= 1
if not (self.image_path and self.image_index):
self.prepare_source()
self.main_menu.position -= 1
self.extract_wim(self.image_path, self.image_index, self.system_part)
self.sync()
self.install_bootloader()
self.main_menu.advance()
def extract_wim(self, wimfile, imageid, target):
r, w = os.pipe()
process = subprocess.Popen(['wimlib-imagex', 'apply', wimfile, imageid, target],
stdout=w, stderr=w)
filp = os.fdopen(r)
self.logger.info('Applying WIM...')
while True:
line = filp.readline()
self.logger.debug('Discarding line from WIM STDOUT: {}'.format(line))
if 'Creating files' in line: break
for stage in ['Creating files', 'Extracting file data']:
self.d.gauge_start(text=stage, width=80, percent=0)
while(True):
line = filp.readline()
self.logger.debug('Wim extraction STDOUT: {}'.format(line))
if stage not in line: continue
pct = re.search(r'\d+%', line).group(0)[:-1]
if pct:
self.d.gauge_update(int(pct))
if pct == '100': break
exit_code = self.d.gauge_stop()
def ntfs_hide(self, path):
subprocess.check_call(['setfattr', '-h', '-v', '0x02000000',
'-n', 'system.ntfs_attrib', path])
def install_bootloader(self):
from . import BCD
mount(self.system_part, self.system_dir, mkdir=True)
if not self.uefi:
self.write_mbr()
shutil.copytree(
os.path.join(self.system_dir, 'Windows/Boot/PCAT'),
os.path.join(self.system_dir, 'Boot'))
shutil.copy2(
os.path.join(self.system_dir, 'Boot/bootmgr'), self.system_dir)
for file in ['Boot', 'bootmgr']:
self.ntfs_hide(os.path.join(self.system_dir, file))
BCD.write_bcd(BCD.bios_bcd, os.path.join(self.system_dir, 'Boot/BCD'))
else:
mount(self.boot_part, self.boot_dir, mkdir=True)
subprocess.check_call(['sgdisk', self.install_drive,
'-U', self.gpt_disk_signature,
'-u 1:' + self.boot_partuuid,
'-u 2:' + self.system_partuuid])
for dir in ['Boot', 'Microsoft']:
os.makedirs(os.path.join(self.boot_dir, 'EFI/' + dir))
shutil.copytree(
os.path.join(self.system_dir, 'Windows/Boot/EFI'),
os.path.join(self.boot_dir, 'EFI/Microsoft/Boot'))
shutil.copyfile(
os.path.join(self.boot_dir, 'EFI/Microsoft/Boot/bootmgfw.efi'),
os.path.join(self.boot_dir, 'EFI/Boot/bootx64.efi'))
BCD.write_bcd(BCD.uefi_bcd,
os.path.join(self.boot_dir, 'EFI/Microsoft/Boot/BCD'))
def write_mbr(self):
subprocess.check_call(['ms-sys', '-S', self.mbr_disk_signature, '-7', self.install_drive],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.logger.info('MBR written to {}'.format(self.install_drive))
def exit(self):
self.running = False
示例5: call
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import gauge_stop [as 别名]
while True:
mmenu, rmenu = d.menu("Que souhaitez vous faire ?", choices = [("(1)", "Lancer Tuxbot"), ("(2)", "Eteindre Tuxbot"), ("(3)", "Mettre à jour Tuxbot"), ("(4)", "Quitter")])
if rmenu == "(1)":
d.gauge_start("Lancement")
d.gauge_update(10)
# try:
# call(["screen", "-S", "tuxbot", "-X","quit"])
# except:
# d.gauge_update(35)
d.gauge_update(40)
call(["screen","-S","tuxbot", "-d", "-m", "python3", "bot.py"])
d.gauge_update(100)
d.gauge_stop()
d.msgbox("Tuxbot est correctement lancé ! Merci de faire .ping sur discord pour vérifier.")
if rmenu == "(2)":
d.gauge_start("Arrêt")
d.gauge_update(10)
call(["screen", "-S", "tuxbot", "-X","quit"])
d.gauge_update(100)
d.gauge_stop()
d.msgbox("Tuxbot s'est correctement arrêté. Faites vite ;-) !")
if rmenu == "(4)":
d.pause("A bientôt !\n(C) 2018 Gnous.EU Dev Team.", seconds=2)
call(["clear"])
exit()