Compare commits

..

No commits in common. "82bc205b48a5133886e51c7af463d9128a2ebb6f" and "72c9855cbe4fed6aeef057d8fe9ce4602d8d03bd" have entirely different histories.

8 changed files with 47 additions and 47 deletions

View File

@ -20,7 +20,7 @@ class SongPage:
srt_str = srtfile.read().encode("utf-8").decode("utf-8-sig") srt_str = srtfile.read().encode("utf-8").decode("utf-8-sig")
parsed_srt = list(srt.parse(srt_str)) parsed_srt = list(srt.parse(srt_str))
except Exception as e: except Exception as e:
print(f"{self.song.path.name}: srt parse error: {e}") print("{}: srt parse error: {}".format(self.song.path.name, e))
root_path = os.path.relpath(self.song.root, self.song.path) root_path = os.path.relpath(self.song.root, self.song.path)
return { return {
"song": self, "song": self,
@ -58,6 +58,7 @@ class Builder:
def display_boolean(self, value): def display_boolean(self, value):
if value: if value:
return Markup("✓") return Markup("✓")
else:
return Markup("✗") return Markup("✗")
def render(self, template, target, context): def render(self, template, target, context):

View File

@ -17,28 +17,28 @@ def options(parser, config, **kwargs):
"--song_folder", "--song_folder",
type=Path, type=Path,
default=config["global"]["song_folder"], default=config["global"]["song_folder"],
help=f"Folder with the song database, defaults to {config['global']['song_folder']}", help="Folder with the song database, defaults to {}".format(config["global"]["song_folder"]),
) )
parser.add_argument( parser.add_argument(
"-l", "-l",
"--lyrics_file", "--lyrics_file",
type=Path, type=Path,
default=config["global"]["lyrics_file"], default=config["global"]["lyrics_file"],
help=f"File with the lyrics of the songs, defaults to {config['global']['lyrics_file']}", help="File with the lyrics of the songs, defaults to {}".format(config["global"]["lyrics_file"]),
) )
parser.add_argument( parser.add_argument(
"-t", "-t",
"--template_folder", "--template_folder",
type=Path, type=Path,
default=config["build"]["template_folder"], default=config["build"]["template_folder"],
help=f"Folder with jinja2 templates, defaults to {config['build']['template_folder']}", help="Folder with jinja2 templates, defaults to {}".format(config["build"]["template_folder"]),
) )
parser.add_argument( parser.add_argument(
"-S", "-S",
"--static_folder", "--static_folder",
type=Path, type=Path,
default=config["build"]["static_folder"], default=config["build"]["static_folder"],
help=f"Folder with static content, defaults to {config['build']['static_folder']}", help="Folder with static content, defaults to {}".format(config["build"]["static_folder"]),
) )

View File

@ -21,23 +21,23 @@ def options(parser, config, **kwargs):
"--song_folder", "--song_folder",
type=Path, type=Path,
default=config["global"]["song_folder"], default=config["global"]["song_folder"],
help=f"Folder with the song database, defaults to {config['global']['song_folder']}", help="Folder with the song database, defaults to {}".format(config["global"]["song_folder"]),
) )
parser.add_argument( parser.add_argument(
"-a", "--api", default=config[name]["api"], help=f"IPFS API server, defaults to {config[name]['api']}." "-a", "--api", default=config[name]["api"], help="IPFS API server, defaults to {}.".format(config[name]["api"])
) )
parser.add_argument( parser.add_argument(
"-r", "-r",
"--realm", "--realm",
default=config[name]["realm"], default=config[name]["realm"],
help=f"IPFS API basic authentication realm, defaults to {config[name]['realm']}.", help="IPFS API basic authentication realm, defaults to {}.".format(config[name]["realm"]),
) )
parser.add_argument( parser.add_argument(
"-p", "-p",
"--pinfile", "--pinfile",
default=config[name]["pinfile"], default=config[name]["pinfile"],
type=Path, type=Path,
help=f"file to store the current ipfs hash, defaults to {config[name]['pinfile']}", help="file to store the current ipfs hash, defaults to {}".format(config[name]["pinfile"]),
) )
@ -59,7 +59,7 @@ def run(args, **kwargs):
args.song_folder.expanduser(), args.song_folder.expanduser(),
] ]
new_hash = subprocess.check_output(command).decode("utf-8").strip() new_hash = subprocess.check_output(command).decode("utf-8").strip()
logger.info("New hash: %s", new_hash) logger.info("New hash: {}".format(new_hash))
# pin in server # pin in server
data = urllib.parse.urlencode( data = urllib.parse.urlencode(
@ -68,8 +68,8 @@ def run(args, **kwargs):
"progress": "false", "progress": "false",
} }
) )
url = f"{args.api}/api/v0/pin/add?{data}" url = "{}/api/v0/pin/add?{}".format(args.api, data)
logger.debug("server pin request: %s", url) logger.debug("server pin request: {}".format(url))
request = urllib.request.Request(url, method="POST") request = urllib.request.Request(url, method="POST")
urllib.request.urlopen(request) urllib.request.urlopen(request)
logger.info("Hash pinned on server.") logger.info("Hash pinned on server.")
@ -81,8 +81,8 @@ def run(args, **kwargs):
"resolve": "true", "resolve": "true",
} }
) )
url = f"{args.api}/api/v0/name/publish?{data}" url = "{}/api/v0/name/publish?{}".format(args.api, data)
logger.debug("server ipns request: %s", url) logger.debug("server ipns request: {}".format(url))
request = urllib.request.Request(url, method="POST") request = urllib.request.Request(url, method="POST")
urllib.request.urlopen(request) urllib.request.urlopen(request)
logger.info("IPNS name updated.") logger.info("IPNS name updated.")
@ -92,7 +92,7 @@ def run(args, **kwargs):
if pinfile.exists(): if pinfile.exists():
with pinfile.open() as f: with pinfile.open() as f:
previous_hash = f.read() previous_hash = f.read()
logger.info("Previous hash: %s", previous_hash) logger.info("Previous hash: {}".format(previous_hash))
else: else:
if not pinfile.parent.exists(): if not pinfile.parent.exists():
pinfile.parent.mkdir() pinfile.parent.mkdir()
@ -108,7 +108,7 @@ def run(args, **kwargs):
] ]
result = subprocess.run(command) result = subprocess.run(command)
if result.returncode != 0: if result.returncode != 0:
logger.info("Previous %s hash not removed: %s", previous_hash, result.stdout) logger.info("Previous {} hash not removed: {}".format(previous_hash, result.stdout))
else: else:
logger.info("Previous hash unpinned on local") logger.info("Previous hash unpinned on local")
@ -118,8 +118,8 @@ def run(args, **kwargs):
"arg": previous_hash, "arg": previous_hash,
} }
) )
url = f"{args.api}/api/v0/pin/rm?{data}" url = "{}/api/v0/pin/rm?{}".format(args.api, data)
logger.debug("server unpin request: %s", url) logger.debug("server unpin request: {}".format(url))
request = urllib.request.Request(url, method="POST") request = urllib.request.Request(url, method="POST")
urllib.request.urlopen(request) urllib.request.urlopen(request)
logger.info("Previous hash unpinned on server") logger.info("Previous hash unpinned on server")

View File

@ -18,39 +18,43 @@ def options(parser, config, **kwargs):
"--song_folder", "--song_folder",
type=Path, type=Path,
default=config["global"]["song_folder"], default=config["global"]["song_folder"],
help=f"Folder with the song database, defaults to {config['global']['song_folder']}", help="Folder with the song database, defaults to {}".format(config["global"]["song_folder"]),
) )
parser.add_argument( parser.add_argument(
"-H", "--host", default=config[name]["host"], help=f"Target server, defaults to {config[name]['host']}." "-H", "--host", default=config[name]["host"], help="Target server, defaults to {}.".format(config[name]["host"])
) )
parser.add_argument( parser.add_argument(
"-u", "-u",
"--user", "--user",
default=config[name]["user"], default=config[name]["user"],
help=f"User in the server, defaults to {config[name]['user']}.", help="User in the server, defaults to {}.".format(config[name]["user"]),
) )
parser.add_argument( parser.add_argument(
"-p", "-p",
"--port", "--port",
default=config[name]["port"], default=config[name]["port"],
type=int, type=int,
help=f"Port of the ssh server, defaults to {config[name]['port']}.", help="Port of the ssh server, defaults to {}.".format(config[name]["port"]),
) )
parser.add_argument( parser.add_argument(
"-d", "-d",
"--destination", "--destination",
default=config[name]["destination"], default=config[name]["destination"],
help=f"Folder of the server, defaults to {config[name]['destination']}", help="Folder of the server, defaults to {}".format(config[name]["destination"]),
) )
def run(args, **kwargs): def run(args, **kwargs):
contents = str(args.song_folder.expanduser()) + "/" contents = str(args.song_folder.expanduser()) + "/"
destination = f"{args.user}@{args.host}:{args.destination}" destination = "{user}@{host}:{folder}".format(
user=args.user,
host=args.host,
folder=args.destination,
)
command = [ command = [
"rsync", "rsync",
"-av", "-av",
f"--rsh=ssh -p {args.port}", "--rsh=ssh -p {}".format(args.port),
contents, contents,
destination, destination,
] ]

View File

@ -17,21 +17,23 @@ def options(parser, config, **kwargs):
"--song_folder", "--song_folder",
type=Path, type=Path,
default=config["global"]["song_folder"], default=config["global"]["song_folder"],
help=f"Folder with the song database, defaults to {config['global']['song_folder']}", help="Folder with the song database, defaults to {}".format(config["global"]["song_folder"]),
) )
parser.add_argument( parser.add_argument(
"-p", "-p",
"--port", "--port",
default=config[name]["port"], default=config[name]["port"],
type=int, type=int,
help=f"Specify alternate port, defaults to {config[name]['port']}", help="Specify alternate port, defaults to {}".format(config[name]["port"]),
) )
parser.add_argument( parser.add_argument(
"--bind", "--bind",
"-b", "-b",
default=config[name]["bind"], default=config[name]["bind"],
metavar="ADDRESS", metavar="ADDRESS",
help="Specify alternate bind address, defaults to {config[name]['bind'] or 'all interfaces'}", help="Specify alternate bind address, defaults to {}".format(
config[name]["bind"] or "all interfaces",
),
) )

View File

@ -1,30 +1,23 @@
Negro Mate static generator Negro Mate static generator
=========================== ===========================
This module provides extra commands to negromate. This module provides extra commands to negromate:
build
negromate build -----
---------------
Static web generator. Updates songs folder with required html files Static web generator. Updates songs folder with required html files
and static content. and static content.
negromate run run
------------- ---
Starts a local web server to try current version. Starts a local web server to try current version.
negromate rsync rsync
--------------- -----
Syncronizes web with a remote folder, ready to be served with any web Syncronizes web with a remote folder, ready to be served with any web
server. server.
Needs the following packages installed: ipfs
----
* rsync
negromate ipfs
--------------
Adds web to local ipfs node and pins remote server, unpinning previous Adds web to local ipfs node and pins remote server, unpinning previous
version. version.
Needs a working local ipfs node. Seek information at https://ipfs.tech/

View File

@ -1,4 +1,4 @@
webvtt-py webvtt-py
Jinja2==3.1.3 Jinja2==3.1.3
ass==0.4.4 ass==0.4.4
negromate.songs=>1.5 negromate.songs==1.3

View File

@ -22,7 +22,7 @@ python_requires = >= 3.4
install_requires = install_requires =
Jinja2 ==3.1.3 Jinja2 ==3.1.3
ass ==0.5.2 ass ==0.5.2
negromate.songs >=1.5 negromate.songs >=1.4
[options.entry_points] [options.entry_points]
negromate.commands = negromate.commands =