-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonLoader.py
More file actions
33 lines (30 loc) · 928 Bytes
/
PythonLoader.py
File metadata and controls
33 lines (30 loc) · 928 Bytes
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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys, getopt, os
from PythonLoaderCore import Plugin
plugin_path = host = port = None
opts = getopt.getopt(sys.argv[1:], "", longopts=["load=", "connect="])[0]
print(opts)
for opt_name, opt_value in opts:
if opt_name == "--load":
path = plugin_path = str(opt_value)
if os.access(plugin_path, os.W_OK) == False:
print("Error: Wrong path!")
sys.exit(-1)
name = os.path.splitext(os.path.split(plugin_path)[1])[0]
elif opt_name == "--connect":
opt_value = str(opt_value).split(":")
if len(opt_value) == 2:
host, port = opt_value
port = int(port)
else:
print("Error: Wrong port!")
sys.exit(-1)
else:
print(f"Error: Wrong param:{opt_name}={opt_value}!")
sys.exit(-1)
if (plugin_path or host or port) == False:
print("Error: More param!")
sys.exit(-1)
print(host, port, path, name) # type: ignore
Plugin(host, port, path, name) # type: ignore