def runCommand(self, args):
        if self.killed(): return
        try:
            searchnow, file2trash, file2edit, url, self.manualsearchsite, autosearchsites, filename, scrollpos = args.split('|')
            # self.logger.debug("manualsearchsite: " + self.manualsearchsite)
            
            if searchnow:
                self.fp.currentalbum = '<conTEXT:reinit>'
                self.searchnow = searchnow
                self.update = True
            if file2trash:
                file2trash = tounicode(file2trash)
                self.logger.debug("trash file: %s", file2trash)
                run("kioclient move", file2trash, "trash:/")
                self.update = True
            if file2edit:
                file2edit = tounicode(file2edit)
                run("kioclient exec", file2edit)
            if url:
                self.logger.debug("CLICKED URL: %s", url)
                run(self.browser, url)
            if self.manualsearchsite:
                self.fp.manualSearch(self.manualsearchsite)
                self.update = True
        
            # self.logger.debug(autosearchsites)
            if (not self.searchnow == searchAllTemporary or searchnow == searchAllTemporary) and autosearchsites != "":
                self.config["autoSearchSites"] = autosearchsites

            self.config["fileName"] = filename
            self.config["scrollPos"] = scrollpos

        except ValueError:
            return
Esempio n. 2
0
def main():
    args = sys.argv[1:]
    if len(args) == 0:
        args = ["--help"]
    parser = OptionParser(usage="usage: treecheck.py [-f <md5file>] <path>")
    parser.add_option(
        "-f",
        "--filename",
        action="store",
        dest="filename",
        type="string",
        help=
        "A file describing the expected directory contents (md5sum.exe file format)"
    )
    (options, args) = parser.parse_args(args)
    path = tounicode(args[0])
    if not os.path.isabs(path):
        path = tounicode(os.getcwd()) + u"/" + path
    assert os.path.exists(path), "Path does not exist: " + path

    if options.filename == "-":
        fo = sys.stdin
    else:
        fo = open(tounicode(options.filename))
    expected = {}
    for line in fo:
        expected[line[34:].strip()] = line[0:32]

    tree = get_tree(path)

    extra_files = []
    diff_files = []
    missing_files = []

    for fn in tree:
        md5 = md5sum_file(fn)
        if fn not in expected:
            extra_files.append(fn)
            print "?", fn
        else:
            if expected[fn] != md5:
                diff_files.append(fn)
                print "M", fn
    for fn in expected.keys():
        if fn not in tree:
            missing_files.append(fn)
            print "D", fn

    if extra_files or diff_files or missing_files:
        print >> sys.stderr, "*** Content does not match"
        sys.exit(1)
Esempio n. 3
0
 def setUp(self):
     self.repopath = tounicode(
         tempfile.mktemp(prefix="boar_test_repository_", dir=TMPDIR))
     repository.create_repository(self.repopath)
     self.repo = repository.Repo(self.repopath)
     self.sessioninfo1 = {"foo": "bar", "name": SESSION_NAME}
     self.fileinfo1 = {"filename": u"testfilename.txt", "md5sum": DATA1_MD5}
     self.fileinfo2 = {"filename": "testfilename2.txt", "md5sum": DATA2_MD5}
     self.fileinfo3 = {"filename": "testfilename3.txt", "md5sum": DATA3_MD5}
Esempio n. 4
0
def main():
    args = sys.argv[1:]
    if len(args) == 0:
        args = ["--help"]
    parser = OptionParser(usage="usage: treecheck.py [-f <md5file>] <path>")
    parser.add_option("-f", "--filename", action="store", dest = "filename", type="string",
                      help="A file describing the expected directory contents (md5sum.exe file format)")
    (options, args) = parser.parse_args(args)
    path = tounicode(args[0])
    if not os.path.isabs(path):
        path = tounicode(os.getcwd()) + u"/" + path
    assert os.path.exists(path), "Path does not exist: " + path

    if options.filename == "-":
        fo = sys.stdin
    else:
        fo = open(tounicode(options.filename))
    expected = {}
    for line in fo:
        expected[line[34:].strip()] = line[0:32]

    tree = get_tree(path)

    extra_files = []
    diff_files = []
    missing_files = []

    for fn in tree:
        md5 = md5sum_file(fn)
        if fn not in expected:
            extra_files.append(fn)
            print "?", fn
        else:
            if expected[fn] != md5:
                diff_files.append(fn)
                print "M", fn
    for fn in expected.keys():
        if fn not in tree:
            missing_files.append(fn)
            print "D", fn

    if extra_files or diff_files or missing_files:
        print >>sys.stderr, "*** Content does not match"
        sys.exit(1)
Esempio n. 5
0
def main():
    args = sys.argv[1:]
    if len(args) != 3:
        print "mkrandfile.py <seed integer> <filesize in bytes> <filename>"
        sys.exit(1)

    seed = int(args.pop(0))
    filesize_kbytes = int(args.pop(0))
    filename = tounicode(args.pop(0))
    md5 = mkrandfile_deterministic(filename, filesize_kbytes, seed=seed)
    print md5 + "  " + filename
Esempio n. 6
0
def main():
    args = sys.argv[1:]
    if len(args) != 3:
        print "mkrandfile.py <seed integer> <filesize in bytes> <filename>"
        sys.exit(1)

    seed = int(args.pop(0))
    filesize_kbytes = int(args.pop(0))
    filename = tounicode(args.pop(0))
    md5 = mkrandfile_deterministic(filename, filesize_kbytes, seed=seed)
    print md5 + "  " + filename
Esempio n. 7
0
def append2PATH(paths, tmp_path):
  """ Appends the given argument to the PATH in the registry.
      The paths argument can contain multiple paths separated by ';'. """
  from common import is_win32, Path, call_read, subprocess, \
    chunks, tounicode, tounicodes
  paths, tmp_path = tounicodes((paths, tmp_path))
  sep = ";"
  path_list = paths.split(sep)

  # 1. Get the current PATH value.
  echo_cmd = ["wine", "cmd.exe", "/c", "echo", "%PATH%"][is_win32:]
  CUR_PATH = call_read(echo_cmd).rstrip('\r\n') # Remove trailing \r\n.
  CUR_PATH = tounicode(CUR_PATH)
  if not is_win32 and '/' in paths: # Convert the Unix paths to Windows paths.
    winepath = lambda p: call_read(["winepath", "-w", p])[:-1]
    path_list = map(winepath, path_list)
    path_list = tounicodes(path_list)

  # 2. Avoid appending the same path(s) again. Strip '\' before comparing.
  op_list = [p.rstrip('\\') for p in CUR_PATH.split(sep)]
  path_list = filter((lambda p: p.rstrip('\\') not in op_list), path_list)
  if not path_list: return

  # 3. Create a temporary reg file.
  paths = sep.join(path_list)
  NEW_PATH = CUR_PATH + sep + paths + '\0' # Join with the current PATH.
  if 1 or is_win32: # Encode in hex.
    NEW_PATH = NEW_PATH.encode('utf-16')[2:].encode('hex')
    NEW_PATH = ','.join(chunks(NEW_PATH, 2)) # Comma separated byte values.
    var_type = 'hex(2)'
  #else: # Escape backslashes and wrap in quotes.
    #NEW_PATH = '"%s"' % NEW_PATH.replace('\\', '\\\\')
    #var_type = 'str(2)'
  # Write to "tmp_path/newpath.reg".
  tmp_reg = Path(tmp_path)/"newpath.reg"
  tmp_reg.open("w", "utf-16").write("""Windows Registry Editor Version 5.00\r
\r
[HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\
Control\\Session Manager\\Environment]\r
"Path"=%s:%s\r\n""" % (var_type, NEW_PATH))

  # 4. Apply the reg file to the registry. "/s" means run silently.
  regedit = ["wine", "regedit.exe", "/s", tmp_reg][is_win32:]
  subprocess.call(regedit)