summaryrefslogtreecommitdiff
path: root/ga_wrapper/wrapper.py
diff options
context:
space:
mode:
Diffstat (limited to 'ga_wrapper/wrapper.py')
-rw-r--r--ga_wrapper/wrapper.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/ga_wrapper/wrapper.py b/ga_wrapper/wrapper.py
index baf7648..a246a68 100644
--- a/ga_wrapper/wrapper.py
+++ b/ga_wrapper/wrapper.py
@@ -6,6 +6,8 @@ purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
'''
+import argparse
+import os.path
import sys
import subprocess
@@ -17,8 +19,40 @@ def fallthrough(args):
def wget_wrapper(args):
print('emulating wget for ', ' '.join(args))
- status = 0
- raise(Exception('Not implemented'))
+ if args[0].endswith('wget'):
+ args = args[1:]
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('src')
+ parser.add_argument('-O')
+ parser.add_argument('-t')
+ parser.add_argument('-T')
+ parser.add_argument('--passive-ftp', action='store_true')
+
+ wgetargs = parser.parse_args(args)
+ src = wgetargs.src
+ out = wgetargs.O
+ (repo, outfile) = os.path.split(out)
+
+ print('source: ', src)
+ print('repo: ', repo)
+ print('outfile: ', outfile)
+
+ os.chdir(repo)
+ proc = subprocess.Popen(['git', 'annex', 'whereis', outfile],
+ stdout=subprocess.PIPE)
+ (stdoutdata, _) = proc.communicate()
+ print('\n'.join(stdoutdata.decode().split()))
+
+ if not 'ok' in stdoutdata.decode().split():
+ raise(Exception())
+
+ proc = subprocess.Popen(['git', 'annex', 'get', outfile],
+ stdout=subprocess.PIPE)
+ (stdoutdata, _) = proc.communicate()
+ print('\n'.join(stdoutdata.decode().split()))
+ status = proc.returncode
+
return status
@@ -27,11 +61,12 @@ def generic_wrapper():
if len(args) <= 1:
raise(Exception())
if args[0].endswith('git-annex-wrapper'):
- del(args[0])
+ args = args[1:]
if args[0].endswith('wget'):
try:
status = wget_wrapper(args)
- except Exception:
+ except Exception as exc:
+ print(exc)
print('Emulation failed, doing real call')
status = fallthrough(args)
else: