pyflakes warnings
This commit is contained in:
parent
4e0a30ab91
commit
87acfe968e
|
@ -4,7 +4,7 @@ import os.path
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from twisted.internet import defer, reactor, task, error
|
from twisted.internet import defer, reactor, task
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
from twisted.python import runtime
|
from twisted.python import runtime
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
|
|
|
@ -243,7 +243,7 @@ def _get_json_for_fragment(options, fragment, method='GET', post_args=None):
|
||||||
data = resp.read()
|
data = resp.read()
|
||||||
try:
|
try:
|
||||||
parsed = simplejson.loads(data)
|
parsed = simplejson.loads(data)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print "Failed to parse reply:\n%s" % (data,)
|
print "Failed to parse reply:\n%s" % (data,)
|
||||||
return []
|
return []
|
||||||
if parsed is None:
|
if parsed is None:
|
||||||
|
|
|
@ -36,7 +36,7 @@ import sys
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from os.path import join, abspath, curdir, exists, split
|
from os.path import join, abspath, curdir, exists
|
||||||
from os import mkdir, listdir, unlink
|
from os import mkdir, listdir, unlink
|
||||||
|
|
||||||
is_windows = (sys.platform == 'win32')
|
is_windows = (sys.platform == 'win32')
|
||||||
|
|
|
@ -471,7 +471,7 @@ class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Rea
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_download_retry(self):
|
def test_download_retry(self):
|
||||||
alice_fname = os.path.join(self.alice_magic_dir, 'blam')
|
alice_fname = os.path.join(self.alice_magic_dir, 'blam')
|
||||||
bob_fname = os.path.join(self.bob_magic_dir, 'blam')
|
# bob_fname = os.path.join(self.bob_magic_dir, 'blam')
|
||||||
|
|
||||||
# Alice creates a file
|
# Alice creates a file
|
||||||
fileutil.write(alice_fname, ''.join(['contents-%04d\n' % i for i in range(1024)]))
|
fileutil.write(alice_fname, ''.join(['contents-%04d\n' % i for i in range(1024)]))
|
||||||
|
@ -955,7 +955,7 @@ class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Reall
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
x = super(SingleMagicFolderTestMixin, self).setUp()
|
super(SingleMagicFolderTestMixin, self).setUp()
|
||||||
temp = self.mktemp()
|
temp = self.mktemp()
|
||||||
self.basedir = abspath_expanduser_unicode(temp.decode(get_filesystem_encoding()))
|
self.basedir = abspath_expanduser_unicode(temp.decode(get_filesystem_encoding()))
|
||||||
self.magicfolder = None
|
self.magicfolder = None
|
||||||
|
|
|
@ -170,32 +170,6 @@ def is_ancestor_path(parent, dirname):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def make_dirs_with_absolute_mode(parent, dirname, mode):
|
|
||||||
"""
|
|
||||||
Make directory `dirname` and chmod it to `mode` afterwards.
|
|
||||||
We chmod all parent directories of `dirname` until we reach
|
|
||||||
`parent`.
|
|
||||||
"""
|
|
||||||
precondition_abspath(parent)
|
|
||||||
precondition_abspath(dirname)
|
|
||||||
if not is_ancestor_path(parent, dirname):
|
|
||||||
raise AssertionError("dirname must be a descendant of parent")
|
|
||||||
|
|
||||||
make_dirs(dirname)
|
|
||||||
while dirname != parent:
|
|
||||||
os.chmod(dirname, mode)
|
|
||||||
# FIXME: doesn't seem to work on Windows for long paths
|
|
||||||
old_dirname, dirname = dirname, os.path.dirname(dirname)
|
|
||||||
_assert(len(dirname) < len(old_dirname), dirname=dirname, old_dirname=old_dirname)
|
|
||||||
|
|
||||||
def is_ancestor_path(parent, dirname):
|
|
||||||
while dirname != parent:
|
|
||||||
# FIXME: doesn't seem to work on Windows for long paths
|
|
||||||
old_dirname, dirname = dirname, os.path.dirname(dirname)
|
|
||||||
if len(dirname) >= len(old_dirname):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def make_dirs(dirname, mode=0777):
|
def make_dirs(dirname, mode=0777):
|
||||||
"""
|
"""
|
||||||
An idempotent version of os.makedirs(). If the dir already exists, do
|
An idempotent version of os.makedirs(). If the dir already exists, do
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import simplejson
|
import simplejson
|
||||||
|
|
||||||
from twisted.web.server import UnsupportedMethod
|
from allmydata.web.common import TokenOnlyWebApi
|
||||||
|
|
||||||
from nevow import rend
|
|
||||||
from nevow.inevow import IRequest
|
|
||||||
|
|
||||||
from allmydata.web.common import WebError, TokenOnlyWebApi
|
|
||||||
|
|
||||||
|
|
||||||
class MagicFolderWebApi(TokenOnlyWebApi):
|
class MagicFolderWebApi(TokenOnlyWebApi):
|
||||||
|
|
|
@ -225,7 +225,7 @@ class INotify(PollMixin):
|
||||||
def wait_until_stopped(self):
|
def wait_until_stopped(self):
|
||||||
try:
|
try:
|
||||||
fileutil.write(os.path.join(self._path.path, u".ignore-me"), "")
|
fileutil.write(os.path.join(self._path.path, u".ignore-me"), "")
|
||||||
except IOError as e:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
return self.poll(lambda: self._state == STOPPED)
|
return self.poll(lambda: self._state == STOPPED)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue