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 from PathType import PathType
import argparse
import os import os
import shutil import shutil
import subprocess import subprocess
...@@ -147,25 +148,31 @@ def create_backup_parser(subparsers): ...@@ -147,25 +148,31 @@ def create_backup_parser(subparsers):
parser.add_argument('dir', type=PathType( parser.add_argument('dir', type=PathType(
type='dir', dash_ok=False type='dir', dash_ok=False
)) ))
parser.add_argument(
'-o', type=argparse.FileType('wb'), help='output file'
)
parser.set_defaults(func=backup_main) parser.set_defaults(func=backup_main)
def backup_main(parsed): def backup_main(parsed):
tarfile = parsed.dir if parsed.o is None:
if tarfile.endswith('/'): tarfile = parsed.dir
tarfile = tarfile[:-1] if tarfile.endswith('/'):
tarfile = tarfile + '.tar.gz' tarfile = tarfile[:-1]
tarfile = tarfile + '.tar.gz'
with open(tarfile, 'wb') as fp: fp = open(tarfile, 'wb')
pcompr = subprocess.Popen([ else:
'gzip' fp = parsed.o
], stdout=fp, stdin=subprocess.PIPE)
pcompr = subprocess.Popen([
ptar = subprocess.Popen([ 'gzip'
"tar", "cvf", '-', parsed.dir ], stdout=fp, stdin=subprocess.PIPE)
], stdout=pcompr.stdin)
ptar.wait() ptar = subprocess.Popen([
"tar", "cvf", '-', parsed.dir
pcompr.stdin.close() ], stdout=pcompr.stdin)
pcompr.wait() 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