-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarfish.py
73 lines (55 loc) · 1.84 KB
/
starfish.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Created by Oceanlight
import argparse
# subprocess -> cpy, bash exec, webbrowser -> open links
import subprocess, webbrowser
from SQLupdate import *
from SQLquery import *
# argparse
# {} required, [] optional, <> not added
# $ this {subjectName ...} [--zoom, -z] [--openurls, -o] <--seturl / --removeurl <url: str>> <--remove (subject)>
# Create the parser (this need a better name btw)
my_parser = argparse.ArgumentParser(
prog='sch',
usage='%(prog)s subject [options]',
description='Open urls and open zoom meetings associated with a subject')
my_parser.add_argument(
'-s',
'--subject',
action='store',
type=str,
required=True
)
my_parser.add_argument(
'-z',
'--zoom',
action='store_true',
help='open zoom meeting associated with specified subject')
my_parser.add_argument(
'-o',
'--openurls',
action='store_true',
help='open urls associated with specified subject'
)
args = my_parser.parse_args()
if (id := getSubjectID(args.subject)) != None:
print(id)
else:
# raise NameError('subject does not exist')
print("Error: subject does not exist - enter an existing subject")
exit()
# this thingy[0] stuff is ridiculous
# but I don't wanna create an array in subjectUrls() either D:
if args.openurls:
for url in getSubjectURLs(id):
webbrowser.open(url, new=1)
if args.zoom:
if (zoomURL := getSubjectZoomURL(id)) != None and (zoomPass := getSubjectZoomPasscode(id)) != None:
# open link in zoom
bashCommand = "open -a zoom.us " + zoomURL
subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
# TODO: automate password entry
# yank zoom password to clipboard (yeah I use vim haha)
subprocess.run("pbcopy", universal_newlines=True, input=zoomPass)
# print(args.subject)
# print(args.zoom)
# print(args.openurls)