Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. Fixes / Improvements #206

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ chunker.c
*.pyo
*.so
docs/usage/*.inc
.idea/
4 changes: 2 additions & 2 deletions attic/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

IN_LONG_VERSION_PY = True
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# git-archive tarball (such as those provided by github's download-from-tag
# feature). Distribution tarballs (build by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains the computed version number.
Expand All @@ -15,7 +15,7 @@


import subprocess
import sys


def run_command(args, cwd=None, verbose=False):
try:
Expand Down
3 changes: 1 addition & 2 deletions attic/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import pwd
import re
import stat
import sys
import time
from datetime import datetime, timezone, timedelta
Expand Down Expand Up @@ -481,7 +480,7 @@ def write_msgpack(filename, d):
with open(filename + '.tmp', 'wb') as fd:
msgpack.pack(d, fd)
fd.flush()
os.fsync(fd)
os.fsync(fd.fileno())
os.rename(filename + '.tmp', filename)


Expand Down
12 changes: 6 additions & 6 deletions attic/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from itertools import islice
import errno
import os
import shutil
import struct
import sys
from zlib import crc32
Expand Down Expand Up @@ -42,7 +41,7 @@ class InvalidRepository(Error):
"""{} is not a valid repository"""

class CheckNeeded(Error):
'''Inconsistency detected. Please run "attic check {}"'''
"""Inconsistency detected. Please run "attic check {}"."""

class ObjectNotFound(Error):
"""Object with key {} not found in repository {}"""
Expand Down Expand Up @@ -80,9 +79,9 @@ def create(self, path):
config.write(fd)

def get_index_transaction_id(self):
indicies = sorted((int(name[6:]) for name in os.listdir(self.path) if name.startswith('index.') and name[6:].isdigit()))
if indicies:
return indicies[-1]
indices = sorted((int(name[6:]) for name in os.listdir(self.path) if name.startswith('index.') and name[6:].isdigit()))
if indices:
return indices[-1]
else:
return None

Expand Down Expand Up @@ -577,6 +576,7 @@ def close_segment(self):
if self._write_fd:
self.segment += 1
self.offset = 0
os.fsync(self._write_fd)
self._write_fd.flush()
os.fsync(self._write_fd.fileno())
self._write_fd.close()
self._write_fd = None
6 changes: 3 additions & 3 deletions attic/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
has_lchflags = hasattr(os, 'lchflags')


# The mtime get/set precison varies on different OS and Python versions
# The mtime get/set precision varies on different OS and Python versions
if 'HAVE_FUTIMENS' in getattr(posix, '_have_functions', []):
st_mtime_ns_round = 0
elif 'HAVE_UTIMES' in sysconfig.get_config_vars():
Expand Down Expand Up @@ -68,7 +68,7 @@ def _assert_dirs_equal_cmp(self, diff):
if has_lchflags:
attrs.append('st_flags')
if not fuse or not os.path.isdir(path1):
# dir nlink is always 1 on our fuse fileystem
# dir nlink is always 1 on our fuse filesystem
attrs.append('st_nlink')
d1 = [filename] + [getattr(s1, a) for a in attrs]
d2 = [filename] + [getattr(s2, a) for a in attrs]
Expand Down Expand Up @@ -109,7 +109,7 @@ def get_tests(suite):


class TestLoader(unittest.TestLoader):
"""A customzied test loader that properly detects and filters our test cases
"""A customized test loader that properly detects and filters our test cases
"""

def loadTestsFromName(self, pattern, module=None):
Expand Down
4 changes: 2 additions & 2 deletions attic/testsuite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import tempfile
import unittest
from attic.helpers import adjust_patterns, exclude_path, Location, format_timedelta, IncludePattern, ExcludePattern, make_path_safe, UpgradableLock, prune_within, prune_split, to_localtime, \
from attic.helpers import adjust_patterns, exclude_path, Location, format_timedelta, ExcludePattern, make_path_safe, UpgradableLock, prune_within, prune_split, \
StableDict, int_to_bigint, bigint_to_int
from attic.testsuite import AtticTestCase
import msgpack
Expand Down Expand Up @@ -139,7 +139,7 @@ class PruneSplitTestCase(AtticTestCase):
def test(self):

def local_to_UTC(month, day):
'Convert noon on the month and day in 2013 to UTC.'
"""Convert noon on the month and day in 2013 to UTC."""
seconds = mktime(strptime('2013-%02d-%02d 12:00' % (month, day), '%Y-%m-%d %H:%M'))
return datetime.fromtimestamp(seconds, tz=timezone.utc)

Expand Down