Compare commits
No commits in common. "ebdac7c89d2d06b2e51e570e4d3e82be46c63d3b" and "218928f033bb0ce3ce34dac9741dd9b94615e55b" have entirely different histories.
ebdac7c89d
...
218928f033
7 changed files with 125 additions and 173 deletions
18
dcc/ls.py
18
dcc/ls.py
|
@ -1,7 +1,6 @@
|
|||
import dcc.config
|
||||
import os
|
||||
|
||||
|
||||
class List(dcc.config.Base):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
@ -14,22 +13,11 @@ class List(dcc.config.Base):
|
|||
case "pwads":
|
||||
self.list(x.name for x in os.scandir(self.pwads) if x.is_dir())
|
||||
case "iwads":
|
||||
self.list(
|
||||
x.name for x in os.scandir(self.iwads)
|
||||
if x.is_file()
|
||||
)
|
||||
self.list(x.name for x in os.scandir(self.iwads) if x.is_file())
|
||||
case "demos":
|
||||
self.list(
|
||||
x.name for x in
|
||||
os.scandir(self.demos.joinpath(parsed_args.wad))
|
||||
if x.name.endswith(".lmp")
|
||||
)
|
||||
self.list(x.name for x in os.scandir(self.demos.joinpath(parsed_args.wad)) if x.name.endswith(".lmp"))
|
||||
case "videos":
|
||||
self.list(
|
||||
x.name for x in
|
||||
os.scandir(self.fabricate.joinpath(parsed_args.wad))
|
||||
if x.name.endswith(".mp4")
|
||||
)
|
||||
self.list(x.name for x in os.scandir(self.fabricate.joinpath(parsed_args.wad)) if x.name.endswith(".mp4"))
|
||||
case _:
|
||||
raise Exception(f"unknown target {parsed_args.target}")
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import sys
|
|||
from cliff.app import App
|
||||
from cliff.commandmanager import CommandManager
|
||||
|
||||
|
||||
class DCC(App):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
|
@ -22,11 +21,9 @@ class DCC(App):
|
|||
def clean_up(self, cmd, result, err):
|
||||
pass
|
||||
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
dcc = DCC()
|
||||
return dcc.run(argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
|
|
@ -2,7 +2,6 @@ import dcc.config
|
|||
import dcc.doom_base
|
||||
import subprocess
|
||||
|
||||
|
||||
class PB(dcc.doom_base.WadMap):
|
||||
def take_action(self, parsed_args):
|
||||
subprocess.run(["ffplay", self.video_path()])
|
||||
|
|
10
dcc/put.py
10
dcc/put.py
|
@ -2,7 +2,6 @@ import boto3
|
|||
import dcc.config
|
||||
import dcc.doom_base
|
||||
|
||||
|
||||
class Put(dcc.doom_base.WadMap):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
@ -14,10 +13,5 @@ class Put(dcc.doom_base.WadMap):
|
|||
demo = self.demo_in_path()
|
||||
bucket = self.target_bucket()
|
||||
print("Uploading {} to bucket {}.".format(demo, bucket))
|
||||
s3_client.upload_file(
|
||||
demo, 'yrriban', bucket,
|
||||
ExtraArgs={
|
||||
'ContentType': 'binary/octet-stream',
|
||||
'ACL': 'public-read'
|
||||
}
|
||||
)
|
||||
s3_client.upload_file(demo, 'yrriban', bucket,
|
||||
ExtraArgs={'ContentType': 'binary/octet-stream', 'ACL': 'public-read'})
|
||||
|
|
36
dcc/ss.py
36
dcc/ss.py
|
@ -5,7 +5,6 @@ import sys
|
|||
import wand.display
|
||||
import wand.image
|
||||
|
||||
|
||||
class SS(dcc.doom_base.WadMap):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
@ -14,39 +13,24 @@ class SS(dcc.doom_base.WadMap):
|
|||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
while not self._try_screenshot(parsed_args.gravity, parsed_args.yolo):
|
||||
pass
|
||||
|
||||
def _try_screenshot(self, gravity, yolo):
|
||||
with wand.image.Image(
|
||||
width=dcc.config.THUMB_WIDTH,
|
||||
height=dcc.config.THUMB_HEIGHT,
|
||||
pseudo="x:"
|
||||
) as img:
|
||||
def try_screenshot():
|
||||
with wand.image.Image(width=dcc.config.THUMB_WIDTH, height=dcc.config.THUMB_HEIGHT, pseudo="x:") as img:
|
||||
img.reset_coords()
|
||||
if (
|
||||
img.size[0] < dcc.config.THUMB_WIDTH
|
||||
or img.size[1] < dcc.config.THUMB_HEIGHT
|
||||
):
|
||||
if not messagebox.askretrycancel(
|
||||
title="DCC", message="Image too small. Try again?"
|
||||
):
|
||||
if img.size[0] < dcc.config.THUMB_WIDTH or img.size[1] < dcc.config.THUMB_HEIGHT:
|
||||
if not messagebox.askretrycancel(title="DCC", message="Image too small. Try again?"):
|
||||
sys.exit("Gave up trying to select an image.")
|
||||
return False
|
||||
img.crop(
|
||||
width=dcc.config.THUMB_WIDTH,
|
||||
height=dcc.config.THUMB_HEIGHT,
|
||||
gravity=gravity
|
||||
)
|
||||
img.crop(width=dcc.config.THUMB_WIDTH,height=dcc.config.THUMB_HEIGHT,gravity=parsed_args.gravity)
|
||||
img.reset_coords()
|
||||
if not yolo:
|
||||
if not parsed_args.yolo:
|
||||
wand.display.display(img)
|
||||
accepted = messagebox.askyesnocancel(
|
||||
title="DCC", message="Is this image acceptable?"
|
||||
)
|
||||
accepted = messagebox.askyesnocancel(title="DCC", message="Is this image acceptable?")
|
||||
if accepted is None:
|
||||
sys.exit("Gave up on image verification")
|
||||
if not accepted:
|
||||
return False
|
||||
img.save(filename=self.base_thumb_path())
|
||||
return True
|
||||
|
||||
while not try_screenshot():
|
||||
pass
|
||||
|
|
|
@ -3,7 +3,6 @@ import sys
|
|||
import wand.drawing
|
||||
import wand.image
|
||||
|
||||
|
||||
def draw_text(img, text, font_size=64):
|
||||
with wand.drawing.Drawing() as draw:
|
||||
draw.font = dcc.config.FONT
|
||||
|
@ -32,10 +31,7 @@ class Text(dcc.doom_base.WadMap):
|
|||
if not parsed_args.nomap:
|
||||
text = "MAP{}: {}".format(parsed_args.map, text)
|
||||
text = "{}\n{}".format(text, parsed_args.demotype)
|
||||
with wand.image.Image(
|
||||
height=dcc.config.THUMB_HEIGHT,
|
||||
width=dcc.config.THUMB_WIDTH
|
||||
) as img:
|
||||
with wand.image.Image(height=dcc.config.THUMB_HEIGHT,width=dcc.config.THUMB_WIDTH) as img:
|
||||
draw_text(img, text)
|
||||
img.trim()
|
||||
img.reset_coords()
|
||||
|
|
10
dcc/thumb.py
10
dcc/thumb.py
|
@ -3,7 +3,6 @@ import dcc.doom_base
|
|||
import wand.color
|
||||
import wand.image
|
||||
|
||||
|
||||
class Thumb(dcc.doom_base.WadMap):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
@ -14,10 +13,7 @@ class Thumb(dcc.doom_base.WadMap):
|
|||
base = self.base_thumb_path()
|
||||
text = self.text_thumb_path()
|
||||
mdoom = self.m_doom_path()
|
||||
with (
|
||||
wand.image.Image(filename=base) as bi,
|
||||
wand.color.Color("transparent") as tc
|
||||
):
|
||||
with wand.image.Image(filename=base) as bi, wand.color.Color("transparent") as tc:
|
||||
with wand.image.Image(filename=text) as ti:
|
||||
ti.border(tc, 5, 5)
|
||||
bi.composite(ti, gravity="south_west")
|
||||
|
@ -27,9 +23,7 @@ class Thumb(dcc.doom_base.WadMap):
|
|||
bi.composite(mdi, gravity="north_west")
|
||||
|
||||
if parsed_args.index:
|
||||
with wand.image.Image(
|
||||
filename=self.output.joinpath("doomed_index.png")
|
||||
) as di:
|
||||
with wand.image.Image(filename=self.output.joinpath("doomed_index.png")) as di:
|
||||
di.border(tc, 1, 1)
|
||||
bi.composite(di, gravity="north_east")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue