"""CrashPlan Restore Automation (win32)""" from __future__ import unicode_literals from __future__ import print_function import imp from pywinauto.controls import common_controls imp.reload(common_controls) from pywinauto import application from time import sleep from pprint import pprint import sys app = application.Application() app.connect(title_re=".*CrashPlan", class_name="SWT_Window0") win = app.top_window() # Activate Restore Tab win.type_keys("^r") win.wait_for_idle() sleep(1) #win.print_control_identifiers() def getChild(node, name): if node is None: return None for item in node.children(): text = item.Text() if text == "": item.EnsureVisible() if name == item.Text(): return item return None def getChildTimeout(node, name, timeout): sleepdef = 0.1 n = 0 text = "" # while ( getChild(node, name) is None) and n < timeout: while( ( text == "") and n < timeout ): try: text = node.children()[0].Text() except: pass n = n + sleepdef if (n % (1 / sleepdef)) == 0: print(".",end="") sys.stdout.flush() sleep(sleepdef) return getChild(node, name) def getItemOne(node, name): if node is None: return None node.EnsureVisible() node.Expand() #while getChild(node,'chargement en cours...') is not None: # sleep(1) item = getChildTimeout(node, name, 60) if item is None: print("ERROR : Not found " + name, end="") sys.stdout.flush() else: print("/", end="") sys.stdout.flush() return item def getItemTree(node, path): names = path.split('/') item = node for name in names: if len(name) > 0: item = getItemOne(item, name) return item def checkItem(item): if item is not None: item.select() win.type_keys('{SPACE}') return True return False def checkItemTree(node, path): return checkItem(getItemTree(node, path)) tree = win.child_window(class_name='SysTreeView32') root = tree.Root() root.select() #checkItemTree(root, "/space/Backups/Server/encfs-find.pgp") #sys.exit(0) fname = "batch" prefix = "/mnt/space_encfs/" errors = [] print("Selecting file " + fname + " with prefix " + prefix) for line in open(fname): line = line.rstrip("\n\r").rstrip() print("Check item " + line + " ... ", end="") sys.stdout.flush() if checkItemTree(root,prefix + line): print(" OK!") else: print(" ERROR !") errors.append(line) print("Done.") print("List of errors :") for line in errors: print(line)