[~] 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:
|
||||
mkdir -p ~/.local/bin
|
||||
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('')
|
||||
print('\rcleared cliboard\n', end='')
|
||||
|
||||
def aioice_tunnel(argv: list[str]) -> None:
|
||||
import aiortc
|
||||
import logging
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
def vpn(argv: list[str]) -> None:
|
||||
python_path : list[str]
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
if (pathlib.Path(__file__).parent / 'env3').exists():
|
||||
python_path = [
|
||||
str(pathlib.Path(__file__).parent / 'env3' / 'bin' / 'python3')
|
||||
]
|
||||
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
|
||||
|
||||
async def test():
|
||||
t1 = aiortc.RTCPeerConnection(
|
||||
configuration=aiortc.RTCConfiguration(
|
||||
iceServers=[
|
||||
aiortc.RTCIceServer(
|
||||
urls=['stun:stun.l.google.com:19302']
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
t2 = t1.createDataChannel('test')
|
||||
t3 = await t1.createOffer()
|
||||
await t1.setLocalDescription(t3)
|
||||
t4 = t1.localDescription
|
||||
print(json.dumps(t4.sdp))
|
||||
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)
|
||||
subprocess.check_call([
|
||||
*python_path,
|
||||
'-m',
|
||||
'online_fxreader.vpn.vpn',
|
||||
*argv,
|
||||
])
|
||||
|
||||
def player_v1(folder_url, item_id):
|
||||
#import sys
|
||||
@ -3746,6 +3725,29 @@ def install(argv: list[str]) -> None:
|
||||
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:
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
logger.setLevel(logging.INFO)
|
||||
@ -3754,26 +3756,39 @@ def commands_cli() -> 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:
|
||||
if sys.argv[1].startswith('media'):
|
||||
msg = media_keys(sys.argv[1:]).get('msg')
|
||||
elif sys.argv[1] == 'status':
|
||||
status(sys.argv[2:])
|
||||
elif sys.argv[1] == 'http-server':
|
||||
http_server(sys.argv[2:])
|
||||
elif sys.argv[1] == 'pass-ssh-osx':
|
||||
pass_ssh_osx(sys.argv[2:])
|
||||
elif sys.argv[1] == 'wl-screenshot':
|
||||
if len(args) > 0 and args[0].startswith('media'):
|
||||
msg = media_keys(args).get('msg')
|
||||
elif options.command is Command.status:
|
||||
status(args)
|
||||
elif options.command is Command.http_server:
|
||||
http_server(args)
|
||||
elif options.command is Command.pass_ssh_osx:
|
||||
pass_ssh_osx(args)
|
||||
elif options.command is Command.wl_screenshot:
|
||||
subprocess.check_call(r'''
|
||||
grim -g "$(slurp)" - | wl-copy
|
||||
''', shell=True)
|
||||
elif sys.argv[1] == 'chrome':
|
||||
chrome(sys.argv[2:])
|
||||
elif sys.argv[1] == 'eternal-oom':
|
||||
eternal_oom(sys.argv[2:])
|
||||
elif sys.argv[1] == 'resilient-vlc':
|
||||
resilient_vlc(sys.argv[2:])
|
||||
elif sys.argv[1] == 'eternal-firefox':
|
||||
elif options.command is Command.chrome:
|
||||
chrome(args)
|
||||
elif options.command is Command.eternal_oom:
|
||||
eternal_oom(args)
|
||||
elif options.command is Command.resilient_vlc:
|
||||
resilient_vlc(args)
|
||||
elif options.command is Command.eternal_firefox:
|
||||
eternal_firefox(
|
||||
profile=sys.argv[2],
|
||||
group_name=sys.argv[3],
|
||||
@ -3781,34 +3796,36 @@ def commands_cli() -> None:
|
||||
debug=json.loads(sys.argv[5]),
|
||||
tabs=sys.argv[6:],
|
||||
)
|
||||
elif sys.argv[1] == 'install':
|
||||
install(sys.argv[2:])
|
||||
elif sys.argv[1] == 'resilient-ethernet':
|
||||
elif options.command is Command.install:
|
||||
install(args)
|
||||
elif options.command is Command.resilient_ethernet:
|
||||
resilient_ethernet(
|
||||
ip_addr=sys.argv[2],
|
||||
ethernet_device=sys.argv[3],
|
||||
)
|
||||
elif sys.argv[1] == 'player':
|
||||
elif options.command is Command.player:
|
||||
player_v1(
|
||||
folder_url=sys.argv[2],
|
||||
item_id=int(sys.argv[3]),
|
||||
)
|
||||
elif sys.argv[1] == 'share-wifi':
|
||||
share_wifi(sys.argv[2:])
|
||||
elif sys.argv[1] == 'socat-ssh':
|
||||
socat_ssh(sys.argv[2:])
|
||||
elif sys.argv[1] == 'gnome-shortcuts':
|
||||
gnome_shortcuts(sys.argv[2:])
|
||||
elif sys.argv[1] == 'sway_sock':
|
||||
elif options.command is Command.share_wifi:
|
||||
share_wifi(args)
|
||||
elif options.command is Command.socat_ssh:
|
||||
socat_ssh(args)
|
||||
elif options.command is Command.gnome_shortcuts:
|
||||
gnome_shortcuts(args)
|
||||
elif options.command is Command.sway_sock:
|
||||
print(sway_sock())
|
||||
elif sys.argv[1] == 'suspend-timer':
|
||||
suspend_timer(sys.argv[2:])
|
||||
elif sys.argv[1] == 'desktop-services':
|
||||
desktop_services(sys.argv[2:])
|
||||
elif sys.argv[1] == 'pm-service':
|
||||
pm_service(sys.argv[2:])
|
||||
elif sys.argv[1] == 'scrap-yt-music':
|
||||
scrap_yt_music(sys.argv[2:])
|
||||
elif options.command is Command.suspend_timer:
|
||||
suspend_timer(args)
|
||||
elif options.command is Command.desktop_services:
|
||||
desktop_services(args)
|
||||
elif options.command is Command.pm_service:
|
||||
pm_service(args)
|
||||
elif options.command is Command.scrap_yt_music:
|
||||
scrap_yt_music(args)
|
||||
elif options.command is Command.vpn:
|
||||
vpn(args)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
except SystemExit:
|
||||
|
@ -12,3 +12,4 @@ cython
|
||||
numpy
|
||||
scoping
|
||||
types-setuptools
|
||||
uvloop
|
||||
|
Loading…
Reference in New Issue
Block a user