diff --git a/dcc/config.py b/dcc/config.py index 1cf6612..85267db 100644 --- a/dcc/config.py +++ b/dcc/config.py @@ -52,7 +52,10 @@ def DemoInPath(wad, mapstr): return sorted(filter(lambda s : re.search("-", str(s)), candidates))[-1] def DemoOutPath(wad, mapstr): - return DEMOS.joinpath(wad).joinpath("{}_map{}.lmp".format(wad, mapstr)) + return DEMOS.joinpath(wad).joinpath(DemoName(wad, mapstr)) def VideoPath(wad, mapstr): return OUTPUT.joinpath(wad).joinpath("{}_map{}.mp4".format(wad, mapstr)) + +def DemoName(wad, mapstr): + return "{}_map{}.lmp".format(wad, mapstr) diff --git a/dcc/put.py b/dcc/put.py new file mode 100644 index 0000000..1c071f6 --- /dev/null +++ b/dcc/put.py @@ -0,0 +1,18 @@ +from cliff.command import Command +import dcc.config +import boto3 + +class Put(Command): + def get_parser(self, prog_name): + parser = super().get_parser(prog_name) + parser.add_argument('wad') + parser.add_argument('map') + return parser + + # TODO: accept configuration for bucket name + def take_action(self, parsed_args): + s3_client = boto3.client('s3') + demo = dcc.config.DemoInPath(parsed_args.wad, parsed_args.map) + s3_client.upload_file( + demo, 'yrriban', 'doom/' + dcc.config.DemoName(parsed_args.wad, parsed_args.map), + ExtraArgs={'ContentType': 'binary/octet-stream'}) diff --git a/setup.py b/setup.py index 53584b1..cea2a31 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ setup( 'play = dcc.play:Play', 'record = dcc.record:Record', 'fabricate = dcc.fabricate:Fabricate', + 'put = dcc.put:Put', ], }, zip_safe=False,