add treefmt and format everything
This commit is contained in:
parent
b2054c4b33
commit
ff9ac63676
9 changed files with 123 additions and 85 deletions
|
@ -1,8 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
defaultDevice=PCH
|
||||
|
||||
start_jack(){
|
||||
start_jack() {
|
||||
|
||||
internal_device_number=-1
|
||||
komplete_device_number=$(aplay -l | grep Vestax | cut -d":" -f1 | cut -d" " -f2)
|
||||
|
@ -39,8 +41,7 @@ start_jack(){
|
|||
#
|
||||
# to find configuration options do
|
||||
# jack_control dp
|
||||
if [[ $device_number -eq -1 ]]
|
||||
then
|
||||
if [[ $device_number -eq -1 ]]; then
|
||||
# we use alsa in reality, but pulse opens up all the pulse
|
||||
# sink and source stuff
|
||||
# jack_control ds pulse # not working for some reason
|
||||
|
@ -48,21 +49,19 @@ start_jack(){
|
|||
jack_control dps device hw:$defaultDevice
|
||||
else
|
||||
jack_control ds alsa
|
||||
jack_control dps device hw:$device_number # use usb card
|
||||
jack_control dps device "hw:$device_number" # use usb card
|
||||
fi
|
||||
|
||||
jack_control dps duplex True # record and playback ports
|
||||
jack_control dps hwmon False # no hardware monitoring
|
||||
jack_control dps rate 48000 # use cd sample rate
|
||||
|
||||
|
||||
# nperiods are the splitup of the
|
||||
# sound-ring-buffer. 2 are ok for internal cards
|
||||
# but for usb you should use 3 because
|
||||
# you can have to write in junks to the card
|
||||
# so there is one backup slice in the middle
|
||||
if [[ $internal_device_number -ne -1 ]]
|
||||
then
|
||||
if [[ $internal_device_number -ne -1 ]]; then
|
||||
jack_control dps nperiods 3
|
||||
fi
|
||||
|
||||
|
@ -82,7 +81,7 @@ start_jack(){
|
|||
jack_control start
|
||||
}
|
||||
|
||||
stop_jack(){
|
||||
stop_jack() {
|
||||
jack_control exit
|
||||
}
|
||||
|
||||
|
@ -92,14 +91,18 @@ status_jack() {
|
|||
jack_control status
|
||||
}
|
||||
|
||||
|
||||
case $1 in
|
||||
start) start_jack
|
||||
start)
|
||||
start_jack
|
||||
;;
|
||||
stop) stop_jack
|
||||
stop)
|
||||
stop_jack
|
||||
;;
|
||||
restart) stop_jack ; start_jack
|
||||
restart)
|
||||
stop_jack
|
||||
start_jack
|
||||
;;
|
||||
*) status_jack
|
||||
*)
|
||||
status_jack
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function stop_program(){
|
||||
function stop_program() {
|
||||
echo "stop $1"
|
||||
sudo systemctl stop $1
|
||||
sudo systemctl stop "$1"
|
||||
}
|
||||
|
||||
function start_program(){
|
||||
function start_program() {
|
||||
echo "start $1"
|
||||
sudo systemctl stop $1
|
||||
sudo systemctl stop "$1"
|
||||
}
|
||||
|
||||
|
||||
function start(){
|
||||
function start() {
|
||||
echo "starting programs again"
|
||||
echo "-----------------------"
|
||||
echo
|
||||
|
@ -22,7 +22,7 @@ function start(){
|
|||
start_program tor.service
|
||||
}
|
||||
|
||||
function stop(){
|
||||
function stop() {
|
||||
echo "stopping programs"
|
||||
echo "-----------------"
|
||||
echo
|
||||
|
@ -34,17 +34,15 @@ function stop(){
|
|||
stop_program tor.service
|
||||
}
|
||||
|
||||
|
||||
# ----
|
||||
# main
|
||||
# ----
|
||||
|
||||
|
||||
stop
|
||||
|
||||
echo
|
||||
echo -n "wait to start again -> "
|
||||
read
|
||||
read -r
|
||||
echo
|
||||
|
||||
start
|
||||
|
|
|
@ -10,7 +10,7 @@ from tempfile import TemporaryDirectory
|
|||
|
||||
|
||||
def nginx_config() -> str:
|
||||
reload_config ="/etc/nginx/nginx.conf"
|
||||
reload_config = "/etc/nginx/nginx.conf"
|
||||
if os.path.exists(reload_config):
|
||||
return reload_config
|
||||
out = subprocess.check_output(["systemctl", "cat", "nginx"])
|
||||
|
@ -26,8 +26,9 @@ def main():
|
|||
config_path = nginx_config()
|
||||
with TemporaryDirectory() as temp_dir:
|
||||
temp_path = os.path.join(temp_dir, "nginx.conf")
|
||||
with open(temp_path, "wb+") as temp_file, \
|
||||
open(config_path, "rb") as config_file:
|
||||
with open(temp_path, "wb+") as temp_file, open(
|
||||
config_path, "rb"
|
||||
) as config_file:
|
||||
shutil.copyfileobj(config_file, temp_file)
|
||||
temp_file.flush()
|
||||
subprocess.check_call(["nginxfmt", temp_file.name])
|
|
@ -19,29 +19,33 @@ class GitLogger:
|
|||
commits = (self.repo.commit(logEntry) for logEntry in self.repo.iter_commits())
|
||||
return (self.to_dict(x) for x in commits)
|
||||
|
||||
def to_dict(self,commit):
|
||||
def to_dict(self, commit):
|
||||
"""create a dict out of a commit that is easy to json serialize"""
|
||||
time_difference = commit.authored_datetime - commit.committed_datetime
|
||||
return {
|
||||
"author_email" : commit.author.email,
|
||||
"author_name" : commit.author.name,
|
||||
"authored_date" : commit.authored_datetime.isoformat(),
|
||||
"files": [{"file":file,"changes":changes} for file,changes in commit.stats.files.items()],
|
||||
"committed_date" : commit.committed_datetime.isoformat(),
|
||||
"committer_email" : commit.committer.email,
|
||||
"committer_name" : commit.committer.name,
|
||||
"date_difference_in_seconds" : abs( time_difference.total_seconds() ),
|
||||
"encoding" : commit.encoding,
|
||||
"hash" : commit.hexsha,
|
||||
"message" : commit.message ,
|
||||
"summary" : commit.summary,
|
||||
"size" : commit.size,
|
||||
"stats_total" : commit.stats.total,
|
||||
"parents" : [parent.hexsha for parent in commit.parents],
|
||||
"author_email": commit.author.email,
|
||||
"author_name": commit.author.name,
|
||||
"authored_date": commit.authored_datetime.isoformat(),
|
||||
"files": [
|
||||
{"file": file, "changes": changes}
|
||||
for file, changes in commit.stats.files.items()
|
||||
],
|
||||
"committed_date": commit.committed_datetime.isoformat(),
|
||||
"committer_email": commit.committer.email,
|
||||
"committer_name": commit.committer.name,
|
||||
"date_difference_in_seconds": abs(time_difference.total_seconds()),
|
||||
"encoding": commit.encoding,
|
||||
"hash": commit.hexsha,
|
||||
"message": commit.message,
|
||||
"summary": commit.summary,
|
||||
"size": commit.size,
|
||||
"stats_total": commit.stats.total,
|
||||
"parents": [parent.hexsha for parent in commit.parents],
|
||||
}
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument("path", type=click.Path(exists=True), envvar='PWD')
|
||||
@click.argument("path", type=click.Path(exists=True), envvar="PWD")
|
||||
@click.option("--host")
|
||||
@click.option("--index")
|
||||
@click.option("--port", default=9200)
|
||||
|
@ -52,24 +56,18 @@ def main(path, host, index, port):
|
|||
exit(1)
|
||||
|
||||
print("Sending commits from %s to %s on index %s" % (path, host, index))
|
||||
es = Elasticsearch([
|
||||
{'host': host, 'port': port}
|
||||
])
|
||||
es = Elasticsearch([{"host": host, "port": port}])
|
||||
for entry in GitLogger(path).log():
|
||||
try:
|
||||
es.index(
|
||||
index=index,
|
||||
doc_type="commit",
|
||||
id=entry["hash"],
|
||||
body=entry
|
||||
)
|
||||
es.index(index=index, doc_type="commit", id=entry["hash"], body=entry)
|
||||
except Exception as e:
|
||||
print(json.dumps(entry))
|
||||
print(e.info)
|
||||
exit(1)
|
||||
else:
|
||||
for entry in GitLogger(path).log():
|
||||
print(json.dumps( entry ))
|
||||
print(json.dumps(entry))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from git import Repo
|
||||
import os
|
||||
|
||||
repo = Repo("/home/palo/dev/nixpkgs")
|
||||
a = repo.head.log()[0]
|
||||
current_hash = a.newhexsha
|
||||
|
@ -7,7 +8,14 @@ commit = repo.commit(current_hash)
|
|||
commit.author
|
||||
commit.committed_date
|
||||
import json
|
||||
json.dumps( { "commit_name" : commit.author.name, "message" : commit.message , "changes": commit.stats.files } )
|
||||
|
||||
json.dumps(
|
||||
{
|
||||
"commit_name": commit.author.name,
|
||||
"message": commit.message,
|
||||
"changes": commit.stats.files,
|
||||
}
|
||||
)
|
||||
commit.committed_date
|
||||
commit.committer.email
|
||||
commit.parents
|
||||
|
|
|
@ -93,6 +93,11 @@ in
|
|||
|
||||
memoryUsage
|
||||
|
||||
treefmt
|
||||
shellcheck
|
||||
shfmt
|
||||
black
|
||||
|
||||
#gitlog2json
|
||||
|
||||
pciutils
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{
|
||||
flakeIgnore = [ "E265" "E225" "W292" ];
|
||||
}
|
||||
(lib.fileContents ../../assets/nginx-show-config.sh);
|
||||
(lib.fileContents ../../assets/nginx-show-config.py);
|
||||
in
|
||||
[
|
||||
pkgs.mosh
|
||||
|
|
|
@ -368,7 +368,7 @@ ssh-keygen -t ed25519 -N "" -f /mnt/etc/secrets/initrd/ssh_host_ed25519_key
|
|||
|
||||
# Install NixOS
|
||||
#PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --no-root-passwd --root /mnt --max-jobs 40
|
||||
PATH="$PATH" `which nixos-install` --no-root-passwd --root /mnt --max-jobs 40
|
||||
PATH="$PATH" $( which nixos-install` --no-root-passwd --root /mnt --max-jobs 40 )
|
||||
|
||||
umount /mnt/boot-{1,2}
|
||||
umount /mnt
|
||||
|
|
25
treefmt.toml
Normal file
25
treefmt.toml
Normal file
|
@ -0,0 +1,25 @@
|
|||
# One CLI to format the code tree - https://github.com/numtide/treefmt
|
||||
|
||||
[formatter.nix]
|
||||
command = "nixpkgs-fmt"
|
||||
includes = [ "*.nix"]
|
||||
|
||||
[formatter.shell]
|
||||
command = "shfmt"
|
||||
options = [
|
||||
"-i",
|
||||
"2", # indent 2
|
||||
"-s", # simplify the code
|
||||
"-w", # write back to the file
|
||||
]
|
||||
includes = ["*.sh"]
|
||||
excludes = ["./scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
|
||||
|
||||
[formatter.shellcheck]
|
||||
command = "shellcheck"
|
||||
includes = ["*.sh"]
|
||||
excludes = ["./scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
|
||||
|
||||
[formatter.python]
|
||||
command = "black"
|
||||
includes = ["*.py"]
|
Loading…
Reference in a new issue