shethjenil
commited on
Commit
•
410ee51
1
Parent(s):
7414e04
Upload 2 files
Browse files- .gitattributes +1 -0
- RUNAPP.exe +3 -0
- RUNAPP.py +46 -0
.gitattributes
CHANGED
@@ -39,3 +39,4 @@ SONG_RECOGNIZER.exe filter=lfs diff=lfs merge=lfs -text
|
|
39 |
HIDEFILE.exe filter=lfs diff=lfs merge=lfs -text
|
40 |
SONGRECOGNIZER.exe filter=lfs diff=lfs merge=lfs -text
|
41 |
PYTOIMAGE.exe filter=lfs diff=lfs merge=lfs -text
|
|
|
|
39 |
HIDEFILE.exe filter=lfs diff=lfs merge=lfs -text
|
40 |
SONGRECOGNIZER.exe filter=lfs diff=lfs merge=lfs -text
|
41 |
PYTOIMAGE.exe filter=lfs diff=lfs merge=lfs -text
|
42 |
+
RUNAPP.exe filter=lfs diff=lfs merge=lfs -text
|
RUNAPP.exe
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e2e46f19bfebe70abde724dafe6bc35e183e2d92a06b831a21050da4c6c18654
|
3 |
+
size 10988501
|
RUNAPP.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from zipfile import ZipFile
|
2 |
+
from subprocess import Popen
|
3 |
+
from os import path , getenv , kill
|
4 |
+
from shutil import rmtree
|
5 |
+
import argparse
|
6 |
+
from tkinter.filedialog import askopenfilename
|
7 |
+
import socket
|
8 |
+
import atexit
|
9 |
+
def check_port(port:int,host:str) -> bool:
|
10 |
+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
11 |
+
try:
|
12 |
+
s.settimeout(1) # Adjust timeout as needed
|
13 |
+
s.connect((host, port))
|
14 |
+
s.close()
|
15 |
+
return True
|
16 |
+
except (socket.timeout, ConnectionRefusedError):
|
17 |
+
return False
|
18 |
+
argparser = argparse.ArgumentParser()
|
19 |
+
argparser.add_argument("-p","--port",type=int,default=12345,help="port number")
|
20 |
+
argparser.add_argument("-a","--host",type=str,default="localhost",help="host address")
|
21 |
+
argparser.add_argument("-i","--image",type=str,help="app image")
|
22 |
+
args = argparser.parse_args()
|
23 |
+
folder = getenv("LOCALAPPDATA")+"\\"+f"JenilSoftware_{args.host}_{args.port}"
|
24 |
+
process = None
|
25 |
+
def kill_process():
|
26 |
+
if process:
|
27 |
+
kill(process.pid)
|
28 |
+
rmtree(folder)
|
29 |
+
atexit.register(kill_process)
|
30 |
+
try:
|
31 |
+
if path.exists(folder):
|
32 |
+
rmtree(folder)
|
33 |
+
image = None
|
34 |
+
if not check_port(args.port,args.host):
|
35 |
+
if args.image:
|
36 |
+
image = args.image
|
37 |
+
else:
|
38 |
+
image = askopenfilename(filetypes=[("Application Image",["*.png"])],defaultextension=".png")
|
39 |
+
ZipFile(image).extractall(folder)
|
40 |
+
process = Popen([folder+r"\main.exe","-p",str(args.port),"-a",str(args.host),"-m","2"],shell=True)
|
41 |
+
process.wait()
|
42 |
+
else:
|
43 |
+
raise Exception("port is not available for app")
|
44 |
+
except Exception as e:
|
45 |
+
print(e)
|
46 |
+
rmtree(folder)
|