Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 962440f8 authored by ulrich_y's avatar ulrich_y
Browse files

Towards a full #6 in #17: output options for tarring

parent 260dbabc
No related branches found
No related tags found
No related merge requests found
from PathType import PathType
import argparse
import os
import shutil
import subprocess
......@@ -147,25 +148,31 @@ def create_backup_parser(subparsers):
parser.add_argument('dir', type=PathType(
type='dir', dash_ok=False
))
parser.add_argument(
'-o', type=argparse.FileType('wb'), help='output file'
)
parser.set_defaults(func=backup_main)
def backup_main(parsed):
tarfile = parsed.dir
if tarfile.endswith('/'):
tarfile = tarfile[:-1]
tarfile = tarfile + '.tar.gz'
with open(tarfile, 'wb') as fp:
pcompr = subprocess.Popen([
'gzip'
], stdout=fp, stdin=subprocess.PIPE)
ptar = subprocess.Popen([
"tar", "cvf", '-', parsed.dir
], stdout=pcompr.stdin)
ptar.wait()
pcompr.stdin.close()
pcompr.wait()
if parsed.o is None:
tarfile = parsed.dir
if tarfile.endswith('/'):
tarfile = tarfile[:-1]
tarfile = tarfile + '.tar.gz'
fp = open(tarfile, 'wb')
else:
fp = parsed.o
pcompr = subprocess.Popen([
'gzip'
], stdout=fp, stdin=subprocess.PIPE)
ptar = subprocess.Popen([
"tar", "cvf", '-', parsed.dir
], stdout=pcompr.stdin)
ptar.wait()
pcompr.stdin.close()
pcompr.wait()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment