1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

version-info.py: fix coding style

This commit is contained in:
Oleg Semyonov 2013-03-12 12:54:07 +02:00
parent 8d6ef5cfe9
commit 8c6f24afef

View File

@ -41,8 +41,8 @@ class Repo:
def _exec(self, cmd): def _exec(self, cmd):
"""Execute git using cmd as arguments""" """Execute git using cmd as arguments"""
self._git = 'git' self._git = 'git'
git = Popen(self._git + " " + cmd, cwd=self._path, git = Popen(self._git + " " + cmd, cwd = self._path,
shell=True, stdout=PIPE, stderr=PIPE) shell = True, stdout = PIPE, stderr = PIPE)
self._out, self._err = git.communicate() self._out, self._err = git.communicate()
self._rc = git.poll() self._rc = git.poll()
@ -262,15 +262,15 @@ def xtrim(string, suffix, length):
if len(string) + len(suffix) <= length: if len(string) + len(suffix) <= length:
return ''.join([string, suffix]) return ''.join([string, suffix])
else: else:
n = length-1-len(suffix) n = length - 1 - len(suffix)
assert n > 0, "length of truncated string+suffix exceeds maximum length" assert n > 0, "length of truncated string+suffix exceeds maximum length"
return ''.join([string[:n], '+', suffix]) return ''.join([string[:n], '+', suffix])
def GetHashofDirs(directory, verbose=0, raw=0): def get_hash_of_dirs(directory, verbose = 0, raw = 0):
"""Return hash of XML files from UAVObject definition directory""" """Return hash of XML files from UAVObject definition directory"""
import hashlib, os import hashlib, os
SHAhash = hashlib.sha1() SHAhash = hashlib.sha1()
if not os.path.exists (directory): if not os.path.exists(directory):
return -1 return -1
try: try:
@ -288,7 +288,6 @@ def GetHashofDirs(directory, verbose=0, raw=0):
f1 = open(filepath, 'rU') f1 = open(filepath, 'rU')
except: except:
# You can't open the file for some reason # You can't open the file for some reason
f1.close()
continue continue
# Compute file hash. Same as running "sha1sum <file>". # Compute file hash. Same as running "sha1sum <file>".
@ -296,7 +295,8 @@ def GetHashofDirs(directory, verbose=0, raw=0):
while 1: while 1:
# Read file in as little chunks # Read file in as little chunks
buf = f1.read(4096) buf = f1.read(4096)
if not buf : break if not buf:
break
f1hash.update(buf) f1hash.update(buf)
f1.close() f1.close()
@ -412,8 +412,8 @@ string given.
BOARD_TYPE = args.type, BOARD_TYPE = args.type,
BOARD_REVISION = args.revision, BOARD_REVISION = args.revision,
SHA1 = sha1(args.image), SHA1 = sha1(args.image),
UAVOSHA1TXT = GetHashofDirs(args.uavodir, verbose=0, raw=1), UAVOSHA1TXT = get_hash_of_dirs(args.uavodir, verbose = 0, raw = 1),
UAVOSHA1 = GetHashofDirs(args.uavodir, verbose=0, raw=0), UAVOSHA1 = get_hash_of_dirs(args.uavodir, verbose = 0, raw = 0),
) )
# Process positional arguments in the form of: # Process positional arguments in the form of: