mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-04-26 23:14:04 +08:00
Merge pull request #159 from trapexit/git2dbcl
enhance git2debcl to work with older python releases
This commit is contained in:
commit
5d5428fbb3
@ -59,9 +59,40 @@ def guess_distribution():
|
|||||||
try:
|
try:
|
||||||
with open('/etc/lsb-release') as f:
|
with open('/etc/lsb-release') as f:
|
||||||
return find_distrib_codename(f)
|
return find_distrib_codename(f)
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
args = ['lsb_release','-c','-s']
|
||||||
|
return subprocess.check_output(args).strip()
|
||||||
except:
|
except:
|
||||||
return 'unknown'
|
return 'unknown'
|
||||||
|
|
||||||
|
def patch_subprocess():
|
||||||
|
if "check_output" not in dir( subprocess ): # duck punch it in!
|
||||||
|
def check_output(*popenargs, **kwargs):
|
||||||
|
r"""Run command with arguments and return its output as a byte string.
|
||||||
|
|
||||||
|
Backported from Python 2.7 as it's implemented as pure python on stdlib.
|
||||||
|
|
||||||
|
>>> check_output(['/usr/bin/python', '--version'])
|
||||||
|
Python 2.6.2
|
||||||
|
"""
|
||||||
|
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
|
||||||
|
output, unused_err = process.communicate()
|
||||||
|
retcode = process.poll()
|
||||||
|
if retcode:
|
||||||
|
cmd = kwargs.get("args")
|
||||||
|
if cmd is None:
|
||||||
|
cmd = popenargs[0]
|
||||||
|
error = subprocess.CalledProcessError(retcode, cmd)
|
||||||
|
error.output = output
|
||||||
|
raise error
|
||||||
|
return output
|
||||||
|
|
||||||
|
subprocess.check_output = check_output
|
||||||
|
|
||||||
|
def main():
|
||||||
|
patch_subprocess()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Generated debian/changelog from git log')
|
parser = argparse.ArgumentParser(description='Generated debian/changelog from git log')
|
||||||
parser.add_argument('--name',type=str,help='Name of package',required=True)
|
parser.add_argument('--name',type=str,help='Name of package',required=True)
|
||||||
parser.add_argument('--version',type=str,help='Place in git history to include upto',default='::guess::')
|
parser.add_argument('--version',type=str,help='Place in git history to include upto',default='::guess::')
|
||||||
@ -93,9 +124,11 @@ for prev in tags[1:]:
|
|||||||
lines = git_log(tag[1],prev[1])
|
lines = git_log(tag[1],prev[1])
|
||||||
for line in lines:
|
for line in lines:
|
||||||
print " * " + line
|
print " * " + line
|
||||||
print
|
|
||||||
|
|
||||||
authorandtime = git_author_and_time(tag[1])
|
authorandtime = git_author_and_time(tag[1])
|
||||||
print(' %s\n' % authorandtime)
|
print(' %s\n' % authorandtime)
|
||||||
|
|
||||||
tag = prev
|
tag = prev
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user