Exemplo n.º 1
0
 def test_zip (self):
   import zipfile
   filepath = utils.TEST_ROOT
   zipped = fs.dir (filepath).zip ()
   unzip_filepath = os.path.join (utils.TEST_ROOT2)
   os.mkdir (unzip_filepath)
   zipfile.ZipFile (zipped).extractall (unzip_filepath)
   self.assertEquals (
     set (f.relative_to (filepath) for f in fs.flat (filepath)),
     set (f.relative_to (unzip_filepath) for f in fs.flat (unzip_filepath))
   )
Exemplo n.º 2
0
 def test_zip(self):
     import zipfile
     filepath = utils.TEST_ROOT
     zipped = fs.dir(filepath).zip()
     unzip_filepath = os.path.join(utils.TEST_ROOT2)
     os.mkdir(unzip_filepath)
     zipfile.ZipFile(zipped).extractall(unzip_filepath)
     self.assertEquals(
         set(f.relative_to(filepath) for f in fs.flat(filepath)),
         set(
             f.relative_to(unzip_filepath)
             for f in fs.flat(unzip_filepath)))
Exemplo n.º 3
0
def sizer(requests_queue, results_queue):
    while True:
        request = requests_queue.get()
        if request is None:
            print "Stopping..."
            break
        else:
            results_queue.put((request, sum(f.size for f in fs.flat(request))))
Exemplo n.º 4
0
def sizer(requests_queue, results_queue):
    while True:
        request = requests_queue.get()
        if request is None:
            print "Stopping..."
            break
        else:
            results_queue.put((request, sum(f.size for f in fs.flat(request))))
Exemplo n.º 5
0
def get_files(path, size_threshold_mb, results, stop_event):
    """Intended to run inside a thread: scan the contents of
  a tree recursively, pushing every file which is at least
  as big as the size threshold onto a results queue. Stop
  if the stop_event is set.
  """
    size_threshold = size_threshold_mb * 1024 * 1024
    for f in fs.flat(path, ignore_access_errors=True):
        if stop_event.isSet(): break
        try:
            if f.size > size_threshold:
                results.put(f)
        except fs.exc.x_winsys:
            continue
Exemplo n.º 6
0
def get_files (path, size_threshold_mb, results, stop_event):
  """Intended to run inside a thread: scan the contents of
  a tree recursively, pushing every file which is at least
  as big as the size threshold onto a results queue. Stop
  if the stop_event is set.
  """
  size_threshold = size_threshold_mb * 1024 * 1024
  for f in fs.flat (path, ignore_access_errors=True):
    if stop_event.isSet (): break
    try:
      if f.size > size_threshold:
        results.put (f)
    except fs.exc.x_winsys:
      continue
Exemplo n.º 7
0
def sizer(requests, results):
    while True:
        root = requests.get()
        if root is None:
            break
        results.put((root, sum(f.size for f in fs.flat(root))))
Exemplo n.º 8
0
def sizer(requests, results):
    while True:
        root = requests.get()
        if root is None:
            break
        results.put((root, sum(f.size for f in fs.flat(root))))
import codecs
from winsys import fs

base = "c:/temp"
with codecs.open("C:\\Users\\your_username\\Documents\\permissions.log",
                 "wb",
                 encoding="utf8") as log:
    for f in fs.flat(base):
        log.write("\n" + f.filepath.relative_to(base) + "\n")
        for ace in f.security().dacl:
            access_flags = fs.FILE_ACCESS.names_from_value(ace.access)
            log.write(u"  %s => %s\n" % (ace.trustee, ", ".join(access_flags)))