From: David Stainton <dstainton415@gmail.com>
Date: Wed, 8 Jul 2015 17:09:15 +0000 (-0700)
Subject: various pyflakes fixes
X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/provisioning?a=commitdiff_plain;h=4e714179f927c154d4b385e8b89441a99247fd7a;p=tahoe-lafs%2Ftahoe-lafs.git

various pyflakes fixes
---

diff --git a/src/allmydata/client.py b/src/allmydata/client.py
index dd5f8be9..cd43ff83 100644
--- a/src/allmydata/client.py
+++ b/src/allmydata/client.py
@@ -14,7 +14,7 @@ from allmydata.immutable.upload import Uploader
 from allmydata.immutable.offloaded import Helper
 from allmydata.control import ControlServer
 from allmydata.introducer.client import IntroducerClient
-from allmydata.util import fileutil, hashutil, base32, pollmixin, log, keyutil, idlib
+from allmydata.util import hashutil, base32, pollmixin, log, keyutil, idlib
 from allmydata.util.encodingutil import get_filesystem_encoding, \
      from_utf8_or_none
 from allmydata.util.fileutil import abspath_expanduser_unicode
diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index f7373f24..e68580c2 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -158,8 +158,7 @@ class MagicFolder(service.MultiService):
             d = defer.succeed(None)
             collective_dirmap, others_list = result
             for dir_name in others_list:
-                # XXX this is broken
-                d.addCallback(lambda x: self._scan_remote(dir_name, collective_dirmap[dir_name][0]))
+                d.addCallback(lambda x, dir_name=dir_name: self._scan_remote(dir_name, collective_dirmap[dir_name][0]))
                 collective_dirmap_d.addCallback(self._filter_scan_batch)
                 collective_dirmap_d.addCallback(self._add_batch_to_download_queue)
             return d
@@ -188,7 +187,7 @@ class MagicFolder(service.MultiService):
             self._stats_provider.count('magic_folder.objects_downloaded', +1)
             return None
         def failed(f):
-            return failure.Failure("download failed")
+            return Failure("download failed")
         def remove_from_pending(result):
             self._download_pending = self._download_pending.difference(set([name]))
         d.addCallbacks(succeeded, failed)
@@ -201,7 +200,7 @@ class MagicFolder(service.MultiService):
 
     def _db_file_is_uploaded(self, childpath):
         """_db_file_is_uploaded returns true if the file was previously uploaded
-        """ 
+        """
         assert self._db != None
         r = self._db.check_file(childpath)
         filecap = r.was_uploaded()
@@ -334,7 +333,7 @@ class MagicFolder(service.MultiService):
                 try:
                     metadata_d = self._upload_dirnode.get_metadata_for(name)
                 except KeyError:
-                    return failure.Failure()
+                    return Failure()
                 return metadata_d
 
             if not os.path.exists(path):
diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py
index b0cc8a23..098bace3 100644
--- a/src/allmydata/scripts/magic_folder_cli.py
+++ b/src/allmydata/scripts/magic_folder_cli.py
@@ -1,14 +1,12 @@
 
 import os, json
 from cStringIO import StringIO
-from twisted.python import usage, failure
+from twisted.python import usage
 
-from allmydata.scripts.common import BaseOptions
 from .common import BaseOptions, BasedirOptions, get_aliases
 from .cli import MakeDirectoryOptions, ListOptions, LnOptions
 import tahoe_ls, tahoe_mv
 from allmydata.util import fileutil
-from allmydata.util.fileutil import abspath_expanduser_unicode
 
 
 INVITE_SEPERATOR = "~"
diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py
index 30527198..c5dc368e 100644
--- a/src/allmydata/test/test_cli_magic_folder.py
+++ b/src/allmydata/test/test_cli_magic_folder.py
@@ -1,5 +1,4 @@
 import os.path
-import urllib
 import re
 import json
 
@@ -8,9 +7,7 @@ from twisted.internet import defer
 
 from allmydata.util import fileutil
 from allmydata.scripts.common import get_aliases
-from allmydata.scripts import cli, runner
 from allmydata.test.no_network import GridTestMixin
-from allmydata.util.encodingutil import quote_output, get_io_encoding
 from .test_cli import CLITestMixin
 from allmydata.scripts import magic_folder_cli
 from allmydata.util.fileutil import abspath_expanduser_unicode
diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py
index f33d5f94..82fa236a 100644
--- a/src/allmydata/test/test_magic_folder.py
+++ b/src/allmydata/test/test_magic_folder.py
@@ -1,10 +1,10 @@
 
-import os, sys, stat, time, json, re
+import os, sys, stat, time
 
 from twisted.trial import unittest
 from twisted.internet import defer
 
-from allmydata.interfaces import IDirectoryNode, NoSuchChildError
+from allmydata.interfaces import IDirectoryNode
 
 from allmydata.util import fake_inotify, fileutil
 from allmydata.util.encodingutil import get_filesystem_encoding, to_filepath
@@ -12,14 +12,12 @@ from allmydata.util.consumer import download_to_data
 from allmydata.test.no_network import GridTestMixin
 from allmydata.test.common_util import ReallyEqualMixin, NonASCIIPathMixin
 from allmydata.test.common import ShouldFailMixin
-from allmydata.test.test_cli import CLITestMixin
 from allmydata.test.test_cli_magic_folder import MagicFolderCLITestMixin
 
 from allmydata.frontends import magic_folder
 from allmydata.frontends.magic_folder import MagicFolder
 from allmydata import backupdb
 from allmydata.util.fileutil import abspath_expanduser_unicode
-from allmydata.util import fileutil
 
 class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqualMixin, NonASCIIPathMixin):
     """
@@ -147,7 +145,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.files_uploaded'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 1))
-        
+
         def _check_move_small_tree(res):
             self.mkdir_nonascii(small_tree_dir)
             fileutil.write(abspath_expanduser_unicode(u"what", base=small_tree_dir), "say when")
@@ -221,7 +219,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(create_test_file)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 1))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
-        
+
         def restart(ignore):
             tahoe_config_file = os.path.join(self.get_clientdir(), "tahoe.cfg")
             tahoe_config = fileutil.read(tahoe_config_file)