Пример #1
0
 def get_widget_input():
     if widget == 'Combobox':  # 默认选择了第一个
         #[shell_params[ip].append(str(instance.current())) for ip in ips]
         [shell_params[ip].append(instance.get()) for ip in ips]
     elif widget == 'MultiCombobox':  # 默认选择第一个,但可能是”“
         for ip, inst in instance:
             if ip not in ips:
                 continue
             _v = inst.get()
             if not _v and not can_be_null:
                 return False
             shell_params[ip].append(_v)
     elif widget == 'Checkbox':  # 默认无勾选
         choose = [str(_v.get()) for _v in instance]
         # 未选择任意一项
         if not can_be_null and len(
                 set(choose)) == 1 and choose[0] == '0':
             return False
         [shell_params[ip].append('@'.join(choose)) for ip in ips]
     elif widget == 'Entry':  # 默认为空
         for ip in ips:
             _v = instance.get()
             if not _v and not can_be_null:
                 return False
             shell_params[ip].append(_v)
     elif widget == 'Text':
         _v = instance.get('1.0', 'end').strip()
         if not _v and not can_be_null:
             return False
         f = '{0}\\__{1}_{2}__.txt'.format(pid_dir, widget, index)
         Common.write_to_file(f, _v)
         [shell_params[ip].append(f) for ip in ips]
     return True
Пример #2
0
 def _mutex(self, ip, lock=True):
     """ 防重入 """
     _lock_file = '{0}\\{1}-{2}.lock'.format(Global.G_PID_DIR, self.task,
                                             ip)
     # 释放锁
     if not lock:
         try:
             Common.remove(_lock_file)
         except:
             pass
         return True
     # 尝试加锁
     if Common.is_file(_lock_file):
         return False
     Common.write_to_file(_lock_file, 'lock')
     return True