[~] Refactor
This commit is contained in:
parent
0ef9268f48
commit
cadec5376a
20
Makefile
20
Makefile
@ -1,3 +1,23 @@
|
|||||||
|
python_clean:
|
||||||
|
rm -fr \
|
||||||
|
~/.local/bin/env3 \
|
||||||
|
deps/com.github.aiortc.aiortc/dist \
|
||||||
|
deps/com.github.aiortc.aiortc/src/online_fxreader/vpn/dist;
|
||||||
|
|
||||||
|
python_put:
|
||||||
|
[[ -f ~/.local/bin/env3 ]] || (\
|
||||||
|
uv venv --system-site-packages --seed ~/.local/bin/env3 && \
|
||||||
|
~/.local/bin/env3/bin/python3 -m pip install uv \
|
||||||
|
);
|
||||||
|
for f in \
|
||||||
|
deps/com.github.aiortc.aiortc/ \
|
||||||
|
deps/com.github.aiortc.aiortc/src/online_fxreader/vpn; do \
|
||||||
|
echo $$f; \
|
||||||
|
[[ -f $$f/dist ]] && continue; \
|
||||||
|
python3 -m build --installer uv $$f; \
|
||||||
|
~/.local/bin/env3/bin/python3 -m uv pip install $$f/dist/*.whl; \
|
||||||
|
done
|
||||||
|
|
||||||
dotfiles_put:
|
dotfiles_put:
|
||||||
mkdir -p ~/.local/bin
|
mkdir -p ~/.local/bin
|
||||||
cp dotfiles/.local/bin/commands ~/.local/bin/commands
|
cp dotfiles/.local/bin/commands ~/.local/bin/commands
|
||||||
|
2
deps/com.github.aiortc.aiortc
vendored
2
deps/com.github.aiortc.aiortc
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 51b55376b1d49c88710a0234de81f30c7663baae
|
Subproject commit 4aed4f16309082285e27082ea52ee2251e8159c6
|
@ -1571,49 +1571,28 @@ def pass_ssh_osx(argv):
|
|||||||
clipboard_set('')
|
clipboard_set('')
|
||||||
print('\rcleared cliboard\n', end='')
|
print('\rcleared cliboard\n', end='')
|
||||||
|
|
||||||
def aioice_tunnel(argv: list[str]) -> None:
|
def vpn(argv: list[str]) -> None:
|
||||||
import aiortc
|
python_path : list[str]
|
||||||
import logging
|
|
||||||
import asyncio
|
|
||||||
import json
|
|
||||||
import sys
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
if (pathlib.Path(__file__).parent / 'env3').exists():
|
||||||
|
python_path = [
|
||||||
async def test():
|
str(pathlib.Path(__file__).parent / 'env3' / 'bin' / 'python3')
|
||||||
t1 = aiortc.RTCPeerConnection(
|
|
||||||
configuration=aiortc.RTCConfiguration(
|
|
||||||
iceServers=[
|
|
||||||
aiortc.RTCIceServer(
|
|
||||||
urls=['stun:stun.l.google.com:19302']
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
)
|
elif (pathlib.Path(__file__).parent.parent.parent.parent / 'm').exists():
|
||||||
)
|
python_path = [
|
||||||
|
str(pathlib.Path(__file__).parent.parent.parent.parent / 'm'),
|
||||||
|
'env',
|
||||||
|
'--',
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
t2 = t1.createDataChannel('test')
|
subprocess.check_call([
|
||||||
t3 = await t1.createOffer()
|
*python_path,
|
||||||
await t1.setLocalDescription(t3)
|
'-m',
|
||||||
t4 = t1.localDescription
|
'online_fxreader.vpn.vpn',
|
||||||
print(json.dumps(t4.sdp))
|
*argv,
|
||||||
t5 = json.loads(sys.stdin.readline())
|
])
|
||||||
assert isinstance(t5, str)
|
|
||||||
await t1.setRemoteDescription(
|
|
||||||
aiortc.RTCSessionDescription(
|
|
||||||
sdp=t5,
|
|
||||||
type='answer'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@t2.on('open')
|
|
||||||
async def send_message():
|
|
||||||
t2.send('shit')
|
|
||||||
|
|
||||||
return locals()
|
|
||||||
|
|
||||||
#t1 = await test()
|
|
||||||
|
|
||||||
#await asyncio.sleep(999)
|
|
||||||
|
|
||||||
def player_v1(folder_url, item_id):
|
def player_v1(folder_url, item_id):
|
||||||
#import sys
|
#import sys
|
||||||
@ -3746,6 +3725,29 @@ def install(argv: list[str]) -> None:
|
|||||||
logger.info(dict(msg='done'))
|
logger.info(dict(msg='done'))
|
||||||
|
|
||||||
|
|
||||||
|
class Command(enum.StrEnum):
|
||||||
|
media = 'media'
|
||||||
|
status = 'status'
|
||||||
|
http_server = 'http-server'
|
||||||
|
pass_ssh_osx = 'pass-ssh-osx'
|
||||||
|
wl_screenshot = 'wl-screenshot'
|
||||||
|
chrome = 'chrome'
|
||||||
|
eternal_oom = 'eternal-oom'
|
||||||
|
resilient_vlc = 'resilient-vlc'
|
||||||
|
eternal_firefox = 'eternal-firefox'
|
||||||
|
install = 'install'
|
||||||
|
resilient_ethernet = 'resilient-ethernet'
|
||||||
|
player = 'player'
|
||||||
|
share_wifi = 'share-wifi'
|
||||||
|
socat_ssh = 'socat-ssh'
|
||||||
|
gnome_shortcuts = 'gnome-shortcuts'
|
||||||
|
sway_sock = 'sway_sock'
|
||||||
|
suspend_timer = 'suspend-timer'
|
||||||
|
desktop_services = 'desktop-services'
|
||||||
|
pm_service = 'pm-service'
|
||||||
|
scrap_yt_music = 'scrap-yt-music'
|
||||||
|
vpn = 'vpn'
|
||||||
|
|
||||||
def commands_cli() -> None:
|
def commands_cli() -> None:
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
@ -3754,26 +3756,39 @@ def commands_cli() -> None:
|
|||||||
|
|
||||||
msg : Optional[str] = None
|
msg : Optional[str] = None
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser('online_fxreader.commands')
|
||||||
|
parser.add_argument(
|
||||||
|
'command',
|
||||||
|
choices=[
|
||||||
|
o.value
|
||||||
|
for o in Command
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
options, args = parser.parse_known_args()
|
||||||
|
|
||||||
|
options.command = Command(options.command)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if sys.argv[1].startswith('media'):
|
if len(args) > 0 and args[0].startswith('media'):
|
||||||
msg = media_keys(sys.argv[1:]).get('msg')
|
msg = media_keys(args).get('msg')
|
||||||
elif sys.argv[1] == 'status':
|
elif options.command is Command.status:
|
||||||
status(sys.argv[2:])
|
status(args)
|
||||||
elif sys.argv[1] == 'http-server':
|
elif options.command is Command.http_server:
|
||||||
http_server(sys.argv[2:])
|
http_server(args)
|
||||||
elif sys.argv[1] == 'pass-ssh-osx':
|
elif options.command is Command.pass_ssh_osx:
|
||||||
pass_ssh_osx(sys.argv[2:])
|
pass_ssh_osx(args)
|
||||||
elif sys.argv[1] == 'wl-screenshot':
|
elif options.command is Command.wl_screenshot:
|
||||||
subprocess.check_call(r'''
|
subprocess.check_call(r'''
|
||||||
grim -g "$(slurp)" - | wl-copy
|
grim -g "$(slurp)" - | wl-copy
|
||||||
''', shell=True)
|
''', shell=True)
|
||||||
elif sys.argv[1] == 'chrome':
|
elif options.command is Command.chrome:
|
||||||
chrome(sys.argv[2:])
|
chrome(args)
|
||||||
elif sys.argv[1] == 'eternal-oom':
|
elif options.command is Command.eternal_oom:
|
||||||
eternal_oom(sys.argv[2:])
|
eternal_oom(args)
|
||||||
elif sys.argv[1] == 'resilient-vlc':
|
elif options.command is Command.resilient_vlc:
|
||||||
resilient_vlc(sys.argv[2:])
|
resilient_vlc(args)
|
||||||
elif sys.argv[1] == 'eternal-firefox':
|
elif options.command is Command.eternal_firefox:
|
||||||
eternal_firefox(
|
eternal_firefox(
|
||||||
profile=sys.argv[2],
|
profile=sys.argv[2],
|
||||||
group_name=sys.argv[3],
|
group_name=sys.argv[3],
|
||||||
@ -3781,34 +3796,36 @@ def commands_cli() -> None:
|
|||||||
debug=json.loads(sys.argv[5]),
|
debug=json.loads(sys.argv[5]),
|
||||||
tabs=sys.argv[6:],
|
tabs=sys.argv[6:],
|
||||||
)
|
)
|
||||||
elif sys.argv[1] == 'install':
|
elif options.command is Command.install:
|
||||||
install(sys.argv[2:])
|
install(args)
|
||||||
elif sys.argv[1] == 'resilient-ethernet':
|
elif options.command is Command.resilient_ethernet:
|
||||||
resilient_ethernet(
|
resilient_ethernet(
|
||||||
ip_addr=sys.argv[2],
|
ip_addr=sys.argv[2],
|
||||||
ethernet_device=sys.argv[3],
|
ethernet_device=sys.argv[3],
|
||||||
)
|
)
|
||||||
elif sys.argv[1] == 'player':
|
elif options.command is Command.player:
|
||||||
player_v1(
|
player_v1(
|
||||||
folder_url=sys.argv[2],
|
folder_url=sys.argv[2],
|
||||||
item_id=int(sys.argv[3]),
|
item_id=int(sys.argv[3]),
|
||||||
)
|
)
|
||||||
elif sys.argv[1] == 'share-wifi':
|
elif options.command is Command.share_wifi:
|
||||||
share_wifi(sys.argv[2:])
|
share_wifi(args)
|
||||||
elif sys.argv[1] == 'socat-ssh':
|
elif options.command is Command.socat_ssh:
|
||||||
socat_ssh(sys.argv[2:])
|
socat_ssh(args)
|
||||||
elif sys.argv[1] == 'gnome-shortcuts':
|
elif options.command is Command.gnome_shortcuts:
|
||||||
gnome_shortcuts(sys.argv[2:])
|
gnome_shortcuts(args)
|
||||||
elif sys.argv[1] == 'sway_sock':
|
elif options.command is Command.sway_sock:
|
||||||
print(sway_sock())
|
print(sway_sock())
|
||||||
elif sys.argv[1] == 'suspend-timer':
|
elif options.command is Command.suspend_timer:
|
||||||
suspend_timer(sys.argv[2:])
|
suspend_timer(args)
|
||||||
elif sys.argv[1] == 'desktop-services':
|
elif options.command is Command.desktop_services:
|
||||||
desktop_services(sys.argv[2:])
|
desktop_services(args)
|
||||||
elif sys.argv[1] == 'pm-service':
|
elif options.command is Command.pm_service:
|
||||||
pm_service(sys.argv[2:])
|
pm_service(args)
|
||||||
elif sys.argv[1] == 'scrap-yt-music':
|
elif options.command is Command.scrap_yt_music:
|
||||||
scrap_yt_music(sys.argv[2:])
|
scrap_yt_music(args)
|
||||||
|
elif options.command is Command.vpn:
|
||||||
|
vpn(args)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
@ -12,3 +12,4 @@ cython
|
|||||||
numpy
|
numpy
|
||||||
scoping
|
scoping
|
||||||
types-setuptools
|
types-setuptools
|
||||||
|
uvloop
|
||||||
|
Loading…
Reference in New Issue
Block a user