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")
parsed_srt = list(srt.parse(srt_str))
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)
return {
"song": self,
@ -58,6 +58,7 @@ class Builder:
def display_boolean(self, value):
if value:
return Markup("✓")
else:
return Markup("✗")
def render(self, template, target, context):

View File

@ -17,28 +17,28 @@ def options(parser, config, **kwargs):
"--song_folder",
type=Path,
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(
"-l",
"--lyrics_file",
type=Path,
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(
"-t",
"--template_folder",
type=Path,
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(
"-S",
"--static_folder",
type=Path,
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",
type=Path,
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(
"-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(
"-r",
"--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(
"-p",
"--pinfile",
default=config[name]["pinfile"],
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(),
]
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
data = urllib.parse.urlencode(
@ -68,8 +68,8 @@ def run(args, **kwargs):
"progress": "false",
}
)
url = f"{args.api}/api/v0/pin/add?{data}"
logger.debug("server pin request: %s", url)
url = "{}/api/v0/pin/add?{}".format(args.api, data)
logger.debug("server pin request: {}".format(url))
request = urllib.request.Request(url, method="POST")
urllib.request.urlopen(request)
logger.info("Hash pinned on server.")
@ -81,8 +81,8 @@ def run(args, **kwargs):
"resolve": "true",
}
)
url = f"{args.api}/api/v0/name/publish?{data}"
logger.debug("server ipns request: %s", url)
url = "{}/api/v0/name/publish?{}".format(args.api, data)
logger.debug("server ipns request: {}".format(url))
request = urllib.request.Request(url, method="POST")
urllib.request.urlopen(request)
logger.info("IPNS name updated.")
@ -92,7 +92,7 @@ def run(args, **kwargs):
if pinfile.exists():
with pinfile.open() as f:
previous_hash = f.read()
logger.info("Previous hash: %s", previous_hash)
logger.info("Previous hash: {}".format(previous_hash))
else:
if not pinfile.parent.exists():
pinfile.parent.mkdir()
@ -108,7 +108,7 @@ def run(args, **kwargs):
]
result = subprocess.run(command)
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:
logger.info("Previous hash unpinned on local")
@ -118,8 +118,8 @@ def run(args, **kwargs):
"arg": previous_hash,
}
)
url = f"{args.api}/api/v0/pin/rm?{data}"
logger.debug("server unpin request: %s", url)
url = "{}/api/v0/pin/rm?{}".format(args.api, data)
logger.debug("server unpin request: {}".format(url))
request = urllib.request.Request(url, method="POST")
urllib.request.urlopen(request)
logger.info("Previous hash unpinned on server")

View File

@ -18,39 +18,43 @@ def options(parser, config, **kwargs):
"--song_folder",
type=Path,
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(
"-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(
"-u",
"--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(
"-p",
"--port",
default=config[name]["port"],
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(
"-d",
"--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):
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 = [
"rsync",
"-av",
f"--rsh=ssh -p {args.port}",
"--rsh=ssh -p {}".format(args.port),
contents,
destination,
]

View File

@ -17,21 +17,23 @@ def options(parser, config, **kwargs):
"--song_folder",
type=Path,
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(
"-p",
"--port",
default=config[name]["port"],
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(
"--bind",
"-b",
default=config[name]["bind"],
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
===========================
This module provides extra commands to negromate.
This module provides extra commands to negromate:
negromate build
---------------
build
-----
Static web generator. Updates songs folder with required html files
and static content.
negromate run
-------------
run
---
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
server.
Needs the following packages installed:
* rsync
negromate ipfs
--------------
ipfs
----
Adds web to local ipfs node and pins remote server, unpinning previous
version.
Needs a working local ipfs node. Seek information at https://ipfs.tech/

View File

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

View File

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