Compare commits
8 Commits
1665458725
...
1665470382
Author | SHA1 | Date | |
---|---|---|---|
4fb575ba62 | |||
44166a2507 | |||
09836efcc4 | |||
1254b543e9 | |||
3838c37b1b | |||
02175cc67e | |||
c9de444432 | |||
a83e4016ab |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,8 +1,8 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
build/
|
build/
|
||||||
config.yaml
|
config.yaml
|
||||||
0xf44ee3942e7dgendata.csv
|
*.csv
|
||||||
0xf44ee3942e7agendata.csv
|
|
||||||
admin-key.ppk
|
admin-key.ppk
|
||||||
token.txt
|
token.txt
|
||||||
*.zip
|
*.zip
|
||||||
|
output.log
|
||||||
|
BIN
IPPigeon.lnk
BIN
IPPigeon.lnk
Binary file not shown.
26
auth.py
Normal file
26
auth.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import ssh
|
||||||
|
import csv
|
||||||
|
from util import fprint
|
||||||
|
from util import find_data_file
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
def login(config, user, password, sysid):
|
||||||
|
fprint("Attempting to login as " + user)
|
||||||
|
filename = sysid + "login.csv"
|
||||||
|
with open(find_data_file(filename), "w", newline="") as f:
|
||||||
|
writer = csv.writer(f)
|
||||||
|
writer.writerows([[user,password,sysid],])
|
||||||
|
fprint("done creating csv")
|
||||||
|
ssh.sftp_send_data(config, filename, 'sendlogin')
|
||||||
|
command = "python3 login_service.py " + sysid
|
||||||
|
ssh.run_ssh(config, command, 'scripts')
|
||||||
|
sleep(1)
|
||||||
|
filename = sysid + "success.txt"
|
||||||
|
if ssh.check_for_file(config, filename, 'receivelogin') == False:
|
||||||
|
filename = sysid + "fail.txt"
|
||||||
|
if ssh.check_for_file(config, filename, 'receivelogin') == False:
|
||||||
|
raise ValueError("Unable to determine login status")
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
@ -5,8 +5,10 @@ sftp:
|
|||||||
keyfile: keyfile-admin.pem
|
keyfile: keyfile-admin.pem
|
||||||
filepath:
|
filepath:
|
||||||
send: /home/ec2-user/Incoming/Incoming_Data
|
send: /home/ec2-user/Incoming/Incoming_Data
|
||||||
login: /home/ec2-user/Incoming/Login
|
sendlogin: /home/ec2-user/Incoming/Login
|
||||||
recieve: /home/ec2-user/Outgoing
|
receive: /home/ec2-user/Outgoing/Outgoing_Data
|
||||||
|
receivelogin: /home/ec2-user/Outgoing/Login
|
||||||
|
scripts: /home/ec2-user/scripts
|
||||||
|
|
||||||
ui:
|
ui:
|
||||||
darkmode: true
|
darkmode: true
|
||||||
|
35
ippigeon.py
35
ippigeon.py
@ -1,4 +1,4 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from multiprocessing import Process, Manager, Pool, TimeoutError, freeze_support, active_children
|
from multiprocessing import Process, Manager, Pool, TimeoutError, freeze_support, active_children
|
||||||
@ -12,6 +12,7 @@ import taskbartool
|
|||||||
import util
|
import util
|
||||||
import netstat
|
import netstat
|
||||||
import ssh
|
import ssh
|
||||||
|
import auth
|
||||||
|
|
||||||
displaydata = None
|
displaydata = None
|
||||||
settings = None
|
settings = None
|
||||||
@ -47,10 +48,15 @@ def netstat_done(res):
|
|||||||
|
|
||||||
def process_done(res):
|
def process_done(res):
|
||||||
fprint("uploading to sftp...")
|
fprint("uploading to sftp...")
|
||||||
ssh.sftp_send_data(res, config, datafile)
|
#ssh.sftp_send_data(res, config, datafile)
|
||||||
#procdata_res = pool.apply_async(ssh.sftp_send_data, (res, config, datafile))
|
procdata_res = pool.apply_async(ssh.sftp_send_data, (config, datafile, 'send'))
|
||||||
|
|
||||||
|
|
||||||
|
def login_done(res):
|
||||||
|
if not res:
|
||||||
|
fprint("Login failure")
|
||||||
|
settings["message"] = "Login failure"
|
||||||
|
else:
|
||||||
|
fprint("Login result in main: " + str(res))
|
||||||
|
|
||||||
|
|
||||||
def killall():
|
def killall():
|
||||||
@ -62,8 +68,8 @@ def killall():
|
|||||||
|
|
||||||
def mainloop(pool):
|
def mainloop(pool):
|
||||||
# worker pool: netstat, netstat cleanup, upload, download, ui tasks
|
# worker pool: netstat, netstat cleanup, upload, download, ui tasks
|
||||||
fprint("start loop")
|
|
||||||
|
|
||||||
|
global counter
|
||||||
global netdata_res
|
global netdata_res
|
||||||
global procdata_res
|
global procdata_res
|
||||||
global rawdata
|
global rawdata
|
||||||
@ -73,13 +79,25 @@ def mainloop(pool):
|
|||||||
#print("killing")
|
#print("killing")
|
||||||
killall()
|
killall()
|
||||||
#print(res.get(timeout=1))
|
#print(res.get(timeout=1))
|
||||||
|
if counter == 0: # runs every INTERVAL
|
||||||
|
fprint("start loop")
|
||||||
if netdata_res is None or netdata_res.ready():
|
if netdata_res is None or netdata_res.ready():
|
||||||
#rawdata = netdata_res.get()
|
#rawdata = netdata_res.get()
|
||||||
#procdata_res = pool.apply_async(process_netstat, (rawdata))
|
#procdata_res = pool.apply_async(process_netstat, (rawdata))
|
||||||
fprint("netstat starting")
|
fprint("netstat starting")
|
||||||
netdata_res = pool.apply_async(netstat.start, callback=netstat_done)
|
netdata_res = pool.apply_async(netstat.start, callback=netstat_done)
|
||||||
#fprint(netdata_res.successful())
|
#fprint(netdata_res.successful())
|
||||||
sleep(interval)
|
|
||||||
|
# runs every 50ms
|
||||||
|
if settings["login"] == True:
|
||||||
|
login_res = pool.apply_async(auth.login, (config, settings["username"], settings["password"], sysid), callback=login_done)
|
||||||
|
#fprint(auth.login(config, settings["username"], settings["password"], sysid))
|
||||||
|
settings["login"] = False
|
||||||
|
|
||||||
|
sleep(interval / (interval * 20.0))
|
||||||
|
counter += 1
|
||||||
|
if counter == interval * 20:
|
||||||
|
counter = 0
|
||||||
|
|
||||||
class Logger(object):
|
class Logger(object):
|
||||||
def __init__(self, filename="output.log"):
|
def __init__(self, filename="output.log"):
|
||||||
@ -114,7 +132,9 @@ if __name__ == '__main__':
|
|||||||
#print(config['sftp']['host'])
|
#print(config['sftp']['host'])
|
||||||
interval = config['core']['interval']
|
interval = config['core']['interval']
|
||||||
displaydata = manager.list(range(2)) # data to be printed
|
displaydata = manager.list(range(2)) # data to be printed
|
||||||
settings = manager.list(range(20)) # configuration
|
settings = manager.dict() # configuration
|
||||||
|
settings["login"] = False
|
||||||
|
settings["loggedin"] = False
|
||||||
killme = manager.Value('d', 0)
|
killme = manager.Value('d', 0)
|
||||||
#killme = False
|
#killme = False
|
||||||
# launch background UI app as process
|
# launch background UI app as process
|
||||||
@ -128,6 +148,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
# launch loop - non-blocking!
|
# launch loop - non-blocking!
|
||||||
|
counter = 0
|
||||||
while(keeprunning):
|
while(keeprunning):
|
||||||
mainloop(pool)
|
mainloop(pool)
|
||||||
|
|
||||||
|
81
out.csv
81
out.csv
@ -1,81 +0,0 @@
|
|||||||
0xf44ee3942e7d,FRAMEWORKWIN,Cole,1664323651
|
|
||||||
firefox.exe,TCP,[2620:f3:8000:5050:2c24:f8cf:930c:11ae]:54350,[2600:9000:2026:d600:a:da5e:7900:93a1]:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,[2620:f3:8000:5050:2c24:f8cf:930c:11ae]:54323,[2606:4700::6812:c039]:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,[2620:f3:8000:5050:2c24:f8cf:930c:11ae]:54295,[2606:4700::6812:8b2f]:443,TIME_WAIT,0
|
|
||||||
tailscale-ipn.exe,TCP,127.0.0.1:63227,127.0.0.1:41112,ESTABLISHED,13244
|
|
||||||
nxnode.bin,TCP,127.0.0.1:63192,127.0.0.1:22753,ESTABLISHED,11476
|
|
||||||
nxnode.bin,TCP,127.0.0.1:63191,127.0.0.1:1550,ESTABLISHED,11476
|
|
||||||
nxnode.bin,TCP,127.0.0.1:63190,127.0.0.1:21667,ESTABLISHED,11476
|
|
||||||
nxclient.bin,TCP,127.0.0.1:62772,127.0.0.1:15334,ESTABLISHED,12168
|
|
||||||
nxclient.bin,TCP,127.0.0.1:62771,127.0.0.1:14346,ESTABLISHED,12168
|
|
||||||
nxclient.bin,TCP,127.0.0.1:62770,127.0.0.1:32580,ESTABLISHED,12168
|
|
||||||
nxnode.bin,TCP,127.0.0.1:62769,127.0.0.1:25001,ESTABLISHED,11476
|
|
||||||
nxnode.bin,TCP,127.0.0.1:62767,127.0.0.1:24790,ESTABLISHED,11476
|
|
||||||
nxnode.bin,TCP,127.0.0.1:62764,127.0.0.1:4831,ESTABLISHED,11476
|
|
||||||
firefox.exe,TCP,127.0.0.1:54101,127.0.0.1:54100,ESTABLISHED,2220
|
|
||||||
firefox.exe,TCP,127.0.0.1:54100,127.0.0.1:54101,ESTABLISHED,2220
|
|
||||||
firefox.exe,TCP,127.0.0.1:54099,127.0.0.1:54098,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,127.0.0.1:54098,127.0.0.1:54099,ESTABLISHED,16812
|
|
||||||
python.exe,TCP,127.0.0.1:53388,127.0.0.1:53387,ESTABLISHED,6380
|
|
||||||
python.exe,TCP,127.0.0.1:53387,127.0.0.1:53388,ESTABLISHED,6380
|
|
||||||
VSCodium.exe,TCP,127.0.0.1:53380,127.0.0.1:53379,ESTABLISHED,9272
|
|
||||||
VSCodium.exe,TCP,127.0.0.1:53379,127.0.0.1:53380,ESTABLISHED,9272
|
|
||||||
nxserver.bin,TCP,127.0.0.1:53359,127.0.0.1:17141,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:53352,127.0.0.1:25137,ESTABLISHED,7620
|
|
||||||
nxservice64.exe,TCP,127.0.0.1:49777,127.0.0.1:19492,ESTABLISHED,5244
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49772,127.0.0.1:7426,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49768,127.0.0.1:15484,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49767,127.0.0.1:7973,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49766,127.0.0.1:4362,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49765,127.0.0.1:5244,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49764,127.0.0.1:2739,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:49704,127.0.0.1:32876,ESTABLISHED,7620
|
|
||||||
AppleMobileDeviceService.exe,TCP,127.0.0.1:49674,127.0.0.1:5354,ESTABLISHED,4888
|
|
||||||
AppleMobileDeviceService.exe,TCP,127.0.0.1:49670,127.0.0.1:5354,ESTABLISHED,4888
|
|
||||||
tailscaled.exe,TCP,127.0.0.1:41112,127.0.0.1:63227,ESTABLISHED,7688
|
|
||||||
nxserver.bin,TCP,127.0.0.1:32876,127.0.0.1:49704,ESTABLISHED,7620
|
|
||||||
nxclient.bin,TCP,127.0.0.1:32580,127.0.0.1:62770,ESTABLISHED,12168
|
|
||||||
nxserver.bin,TCP,127.0.0.1:25137,127.0.0.1:53352,ESTABLISHED,7620
|
|
||||||
nxclient.bin,TCP,127.0.0.1:25001,127.0.0.1:62769,ESTABLISHED,12168
|
|
||||||
nxserver.bin,TCP,127.0.0.1:24790,127.0.0.1:62767,ESTABLISHED,7620
|
|
||||||
nxnode.bin,TCP,127.0.0.1:22753,127.0.0.1:63192,ESTABLISHED,11476
|
|
||||||
nxnode.bin,TCP,127.0.0.1:21667,127.0.0.1:63190,ESTABLISHED,11476
|
|
||||||
nxservice64.exe,TCP,127.0.0.1:19492,127.0.0.1:49777,ESTABLISHED,5244
|
|
||||||
nxserver.bin,TCP,127.0.0.1:17141,127.0.0.1:53359,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:15484,127.0.0.1:49768,ESTABLISHED,7620
|
|
||||||
nxclient.bin,TCP,127.0.0.1:15334,127.0.0.1:62772,ESTABLISHED,12168
|
|
||||||
nxclient.bin,TCP,127.0.0.1:14346,127.0.0.1:62771,ESTABLISHED,12168
|
|
||||||
nxserver.bin,TCP,127.0.0.1:7973,127.0.0.1:49767,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:7426,127.0.0.1:49772,ESTABLISHED,7620
|
|
||||||
mDNSResponder.exe,TCP,127.0.0.1:5354,127.0.0.1:49674,ESTABLISHED,4948
|
|
||||||
mDNSResponder.exe,TCP,127.0.0.1:5354,127.0.0.1:49670,ESTABLISHED,4948
|
|
||||||
nxserver.bin,TCP,127.0.0.1:5244,127.0.0.1:49765,ESTABLISHED,7620
|
|
||||||
nxnode.bin,TCP,127.0.0.1:4831,127.0.0.1:62764,ESTABLISHED,11476
|
|
||||||
nxserver.bin,TCP,127.0.0.1:4362,127.0.0.1:49766,ESTABLISHED,7620
|
|
||||||
nxserver.bin,TCP,127.0.0.1:2739,127.0.0.1:49764,ESTABLISHED,7620
|
|
||||||
nxnode.bin,TCP,127.0.0.1:1550,127.0.0.1:63191,ESTABLISHED,11476
|
|
||||||
nxnode.bin,TCP,104.194.96.68:54361,208.59.79.12:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54352,52.84.125.26:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54348,35.244.181.201:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54347,52.84.52.31:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54346,52.84.52.31:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54345,52.84.52.31:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54344,52.84.52.31:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54343,52.84.52.31:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54342,52.84.52.31:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54341,52.84.52.87:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54340,54.185.157.183:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54339,35.186.227.140:443,ESTABLISHED,16812
|
|
||||||
firefox.exe,TCP,104.194.96.68:54338,54.201.164.58:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54330,52.84.125.36:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54293,141.193.213.11:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54276,104.21.42.46:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54271,104.21.42.46:443,TIME_WAIT,0
|
|
||||||
firefox.exe,TCP,104.194.96.68:54110,52.41.253.170:443,ESTABLISHED,16812
|
|
||||||
syncthing.exe,TCP,104.194.96.68:53909,128.173.88.78:22067,ESTABLISHED,6668
|
|
||||||
tailscaled.exe,TCP,104.194.96.68:53392,18.156.90.224:80,ESTABLISHED,7688
|
|
||||||
tailscaled.exe,TCP,104.194.96.68:53214,199.38.182.118:443,ESTABLISHED,7688
|
|
||||||
svchost.exe,TCP,104.194.96.68:49420,13.64.180.106:443,ESTABLISHED,5456
|
|
||||||
VcomSvc.exe,TCP,100.106.209.107:63898,192.168.1.173:5000,ESTABLISHED,5424
|
|
||||||
Windows System,TCP,100.106.209.107:53857,192.168.1.11:445,ESTABLISHED,4
|
|
||||||
Windows System,TCP,100.106.209.107:53856,192.168.1.216:445,ESTABLISHED,4
|
|
|
45258
output.log
45258
output.log
File diff suppressed because it is too large
Load Diff
26
release.sh
26
release.sh
@ -11,8 +11,11 @@ export PATH=$PATH:"C:\Program Files\7-Zip"
|
|||||||
TAG=$(date +%s)
|
TAG=$(date +%s)
|
||||||
"C:/Program Files/Python310/python.exe" setup.py build
|
"C:/Program Files/Python310/python.exe" setup.py build
|
||||||
sleep 2
|
sleep 2
|
||||||
7z a -r release-$COMMIT.zip ./build/exe.win-amd64-3.10/*
|
mv ./build/exe.win-amd64-3.10/ ./build/ippigeon-win
|
||||||
|
7z a -r release-$COMMIT.zip ./build/ippigeon-win
|
||||||
|
7z a -sfx7z.sfx IPPigeon-install.exe ./build/ippigeon-win
|
||||||
|
mv ./build/ippigeon-win/ ./build/exe.win-amd64-3.10
|
||||||
|
#sleep 30
|
||||||
DATA='{
|
DATA='{
|
||||||
"body": "Autogenerated release",
|
"body": "Autogenerated release",
|
||||||
"draft": false,
|
"draft": false,
|
||||||
@ -33,9 +36,22 @@ OUT=$(curl -X 'POST' \
|
|||||||
'https://git.deck.sh/api/v1/repos/Interfaz/ff/releases/'$ID'/assets?token='$TOKEN'' \
|
'https://git.deck.sh/api/v1/repos/Interfaz/ff/releases/'$ID'/assets?token='$TOKEN'' \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
-H 'Content-Type: multipart/form-data' \
|
-H 'Content-Type: multipart/form-data' \
|
||||||
-F 'attachment=@'release-$COMMIT.zip';type=application/x-zip-compressed')
|
-F 'attachment=@IPPigeon-install.exe;type=application/octet-stream')
|
||||||
|
|
||||||
URL=$(echo $OUT | cut -d',' -f 7 | cut -d\" -f4)
|
URL=$(echo $OUT | cut -d',' -f 7 | cut -d\" -f4)
|
||||||
echo $URL
|
|
||||||
curl -d "$URL" https://notify.deck.sh/ipro-release
|
|
||||||
|
|
||||||
|
OUT=$(curl -X 'POST' \
|
||||||
|
'https://git.deck.sh/api/v1/repos/Interfaz/ff/releases/'$ID'/assets?token='$TOKEN'' \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H 'Content-Type: multipart/form-data' \
|
||||||
|
-F 'attachment=@'release-$COMMIT.zip';type=application/x-zip-compressed')
|
||||||
|
|
||||||
|
URLZIP=$(echo $OUT | cut -d',' -f 7 | cut -d\" -f4)
|
||||||
|
curl -d "Self extracting installer: $URL
|
||||||
|
|
||||||
|
Portable Zip: $URLZIP" https://notify.deck.sh/ipro-release
|
||||||
|
|
||||||
rm release-$COMMIT.zip
|
rm release-$COMMIT.zip
|
||||||
|
rm IPPigeon-install.exe
|
2
run.sh
Normal file
2
run.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"C:/Program Files/Python310/python.exe" setup.py build
|
||||||
|
|
6
setup.py
6
setup.py
@ -2,10 +2,10 @@ import sys
|
|||||||
from cx_Freeze import setup, Executable
|
from cx_Freeze import setup, Executable
|
||||||
|
|
||||||
debug = True
|
debug = True
|
||||||
debug = not debug
|
#debug = not debug
|
||||||
# Dependencies are automatically detected, but it might need fine tuning.
|
# Dependencies are automatically detected, but it might need fine tuning.
|
||||||
# "packages": ["os"] is used as example only
|
# "packages": ["os"] is used as example only
|
||||||
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"], "include_msvcr": True, "include_files": ["icon.png", "IPPigeon.lnk", "config.yml", "keyfile-admin.pem"], "optimize": 2}
|
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"], "include_msvcr": True, "include_files": ["icon.png", "config.yml", "keyfile-admin.pem"], "optimize": 2}
|
||||||
|
|
||||||
# base="Win32GUI" should be used only for Windows GUI app
|
# base="Win32GUI" should be used only for Windows GUI app
|
||||||
base = None
|
base = None
|
||||||
@ -17,5 +17,5 @@ setup(
|
|||||||
version="0.2.4",
|
version="0.2.4",
|
||||||
description="IP Pigeon client application",
|
description="IP Pigeon client application",
|
||||||
options={"build_exe": build_exe_options},
|
options={"build_exe": build_exe_options},
|
||||||
executables=[Executable("ippigeon.py", base=base)],
|
executables=[Executable("ippigeon.py", base=base, icon="icon.ico", uac_admin=True, target_name="IPPigeon.exe")],
|
||||||
)
|
)
|
33
ssh.py
33
ssh.py
@ -1,14 +1,39 @@
|
|||||||
|
#from __future__ import with_statement
|
||||||
from fabric import Connection
|
from fabric import Connection
|
||||||
from util import find_data_file
|
from util import find_data_file
|
||||||
from util import setup_child
|
from util import setup_child
|
||||||
from util import fprint
|
from util import fprint
|
||||||
|
from invoke import exceptions
|
||||||
|
import sys
|
||||||
|
|
||||||
def sftp_send_data(res, config, filename):
|
def sftp_send_data(config, filename, filetype):
|
||||||
setup_child()
|
setup_child()
|
||||||
fprint("Connecting over SSH to " + config['sftp']['host'])
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
||||||
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
||||||
fprint("Sending data over SFTP: " + filename)
|
fprint("Sending data over SFTP: " + filename)
|
||||||
fprint(c.put(find_data_file(filename), remote=config['sftp']['filepath']['send']))
|
fprint(c.put(find_data_file(filename), remote=config['sftp']['filepath'][filetype]))
|
||||||
fprint("Data sent over SFTP sucessfully")
|
fprint("Data sent over SFTP successfully")
|
||||||
#command = 'ls ' + config['sftp']['filepath']['send']
|
#command = 'ls ' + config['sftp']['filepath'][filetype]
|
||||||
#fprint(c.run(command))
|
#fprint(c.run(command))
|
||||||
|
|
||||||
|
def check_for_file(config, filename, location):
|
||||||
|
setup_child()
|
||||||
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
||||||
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
||||||
|
fprint("Checking for existence of file " + config['sftp']['filepath'][location] + "/" + filename)
|
||||||
|
try:
|
||||||
|
res = c.run("ls -l " + config['sftp']['filepath'][location] + "/" + filename, hide=True)
|
||||||
|
fprint("File " + filename + " exists!")
|
||||||
|
return c.run("cat " + config['sftp']['filepath'][location] + "/" + filename, hide=True)
|
||||||
|
except exceptions.UnexpectedExit:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def run_ssh(config, command, location):
|
||||||
|
setup_child()
|
||||||
|
fprint("Connecting over SSH to " + config['sftp']['host'])
|
||||||
|
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
||||||
|
fprint("cd to " + config['sftp']['filepath'][location])
|
||||||
|
with c.cd(config['sftp']['filepath'][location]):
|
||||||
|
fprint("Running ssh command: " + command)
|
||||||
|
res = c.run(command, hide=True, asynchronous=True)
|
||||||
|
return res
|
||||||
|
@ -31,6 +31,7 @@ class TaskBarIcon(wx.adv.TaskBarIcon):
|
|||||||
def CreatePopupMenu(self):
|
def CreatePopupMenu(self):
|
||||||
menu = wx.Menu()
|
menu = wx.Menu()
|
||||||
create_menu_item(menu, 'Control Panel', self.on_open)
|
create_menu_item(menu, 'Control Panel', self.on_open)
|
||||||
|
create_menu_item(menu, 'Login test', self.on_login)
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
create_menu_item(menu, 'Exit', self.on_exit)
|
create_menu_item(menu, 'Exit', self.on_exit)
|
||||||
return menu
|
return menu
|
||||||
@ -46,6 +47,11 @@ class TaskBarIcon(wx.adv.TaskBarIcon):
|
|||||||
foreground()
|
foreground()
|
||||||
#self.close_popup()
|
#self.close_popup()
|
||||||
|
|
||||||
|
def on_login(self, event):
|
||||||
|
settings["username"] = "Cole"
|
||||||
|
settings["password"] = "12345"
|
||||||
|
settings["login"] = True
|
||||||
|
|
||||||
def on_exit(self, event):
|
def on_exit(self, event):
|
||||||
wx.CallAfter(self.Destroy)
|
wx.CallAfter(self.Destroy)
|
||||||
self.close_popup()
|
self.close_popup()
|
||||||
@ -65,6 +71,8 @@ class TaskbarApp(wx.App):
|
|||||||
|
|
||||||
def background(data, sets, kill):
|
def background(data, sets, kill):
|
||||||
global killme
|
global killme
|
||||||
|
global settings
|
||||||
|
global displaydata
|
||||||
killme = kill
|
killme = kill
|
||||||
app = TaskbarApp(False)
|
app = TaskbarApp(False)
|
||||||
displaydata = data
|
displaydata = data
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
import wx.adv
|
|
||||||
import wx
|
|
||||||
TRAY_TOOLTIP = 'Name'
|
|
||||||
TRAY_ICON = 'icon.png'
|
|
||||||
|
|
||||||
|
|
||||||
def create_menu_item(menu, label, func):
|
|
||||||
item = wx.MenuItem(menu, -1, label)
|
|
||||||
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
|
|
||||||
menu.Append(item)
|
|
||||||
return item
|
|
||||||
|
|
||||||
|
|
||||||
class TaskBarIcon(wx.adv.TaskBarIcon):
|
|
||||||
def __init__(self, frame):
|
|
||||||
self.frame = frame
|
|
||||||
super(TaskBarIcon, self).__init__()
|
|
||||||
self.set_icon(TRAY_ICON)
|
|
||||||
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
|
|
||||||
|
|
||||||
def CreatePopupMenu(self):
|
|
||||||
menu = wx.Menu()
|
|
||||||
create_menu_item(menu, 'Site', self.on_hello)
|
|
||||||
menu.AppendSeparator()
|
|
||||||
create_menu_item(menu, 'Exit', self.on_exit)
|
|
||||||
return menu
|
|
||||||
|
|
||||||
def set_icon(self, path):
|
|
||||||
icon = wx.Icon(path)
|
|
||||||
self.SetIcon(icon, TRAY_TOOLTIP)
|
|
||||||
|
|
||||||
def on_left_down(self, event):
|
|
||||||
print ('Tray icon was left-clicked.')
|
|
||||||
|
|
||||||
def on_hello(self, event):
|
|
||||||
print ('Hello, world!')
|
|
||||||
|
|
||||||
def on_exit(self, event):
|
|
||||||
wx.CallAfter(self.Destroy)
|
|
||||||
self.frame.Close()
|
|
||||||
|
|
||||||
class App(wx.App):
|
|
||||||
def OnInit(self):
|
|
||||||
frame=wx.Frame(None)
|
|
||||||
self.SetTopWindow(frame)
|
|
||||||
TaskBarIcon(frame)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def main():
|
|
||||||
app = App(False)
|
|
||||||
app.MainLoop()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
2
util.py
2
util.py
@ -70,7 +70,7 @@ def run_ps(cmd):
|
|||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW # , "-WindowStyle", "hidden"
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW # , "-WindowStyle", "hidden"
|
||||||
fprint("running PS command: " + cmd)
|
fprint("running PS command: " + cmd)
|
||||||
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
||||||
fprint("ran PS command sucessfully")
|
fprint("ran PS command successfully")
|
||||||
#completed = subprocess.run(["powershell", "-WindowStyle", "hidden", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
#completed = subprocess.run(["powershell", "-WindowStyle", "hidden", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
||||||
|
|
||||||
return completed
|
return completed
|
||||||
|
Reference in New Issue
Block a user