Commit 32be77e2 by Juan

primeros pasos listos

1 parent 54095614
#!/bin/bash
sshpass -p $1 ssh $2@$5 -p $3 -D $4 -N &>/dev/null &
sleep 2
google-chrome --proxy-server="socks5://127.0.0.1:$4" $6 $7
sleep 1
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
exit 0
\ No newline at end of file \ No newline at end of file
### Sistema sensillo para gestionar perfiles de google chrome
\ No newline at end of file \ No newline at end of file
Alfabeto = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"X", "W", "Y", "Z"]
\ No newline at end of file \ No newline at end of file
No preview for this file type
No preview for this file type
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5 import QtWidgets
import os
import sys
import tempfile
import subprocess
class AppThread(QThread):
signal = pyqtSignal('PyQt_PyObject')
def __init__(self):
QThread.__init__(self)
self.aplicativo = ""
# run method gets called when we start the thread
def run(self):
#tmpdir = tempfile.mkdtemp()
cmd = "python3 {0}".format(self.aplicativo)
subprocess.check_output(cmd.split())
# git clone done, now inform the main thread with the output
#self.signal.emit(tmpdir)
class LanzarThread(QThread):
signal = pyqtSignal('PyQt_PyObject')
def __init__(self):
QThread.__init__(self)
self.comando = ""
def run(self):
#print('ejecutar ' )
cmd = "{0}".format(self.comando)
print('ejecutar ', cmd )
subprocess.check_output(cmd.split())
class LanzarArchivos(QThread):
signal = pyqtSignal('PyQt_PyObject')
def __init__(self):
QThread.__init__(self)
self.comando = ""
def run(self):
#print('ejecutar ' )
cmd = "{0}".format(self.comando)
print(['xdg-open', cmd])
subprocess.check_output(['xdg-open', cmd])
def escrivir_txt(path, texto):
try:
f = open(path, 'w+')
for i in texto:
f.write(i)
f.close()
return(True)
except:
return(False)
def leer_archivo(path):
texto = []
try:
f = open(path, 'r')
f1 = f.readlines()
for x in f1:
texto.append(x)
return(texto)
except:
return(False)
def path():
DEFAULT_PATH = os.path.abspath('./')
return(DEFAULT_PATH)
def buscar_aplicativos(path):
#print(os.listdir(path + '/'))
folder = []
for file in os.listdir(path + '/'):
if file.endswith("_main.py"):
#print(os.path.join(path, file))
folder.append([os.path.join(path, file), file, file[:-3]])
print([os.path.join(path, file), file, file[:-3]])
return(folder)
#print(path('desktop/dier.py'))
def carga_dinamica():
DEFAULT_PATH = path()
modulos = buscar_aplicativos(DEFAULT_PATH)
print(modulos)
devolucion = []
for modulo in modulos:
modulo = modulo[2]
#print(modulo)
retorno = __import__(modulo)
retorno = retorno.nombre()
print(retorno)
devolucion.append(retorno)
return(devolucion)
def lanzar_aplicativo(self, app, item):
DEFAULT_PATH = path()
modulos = buscar_aplicativos(DEFAULT_PATH)
for modulo in modulos:
PY_modulo = modulo[2]
retorno = __import__(PY_modulo)
retorno = retorno.nombre()
#print(retorno)
if retorno[0] == item:
print('lanzar ' + str(item))
self.app_thread = AppThread()
self.app_thread.aplicativo = modulo[0]
self.app_thread.start()
return(True)
print('no se encontro aplicativo')
return(False)
def ejecutar(self, comando):
try:
self.app_thread = LanzarThread()
self.app_thread.comando = comando
self.app_thread.start()
except:
return(False)
def escrivir_tuple(path, TUPLE):
try:
f = open(path, 'w+')
for i in TUPLE:
f.write(i)
f.write('\n')
f.close()
return(True)
except:
return(False)
def leer_tuple(path):
texto = []
try:
f = open(path, 'r')
f1 = f.readlines()
for x in f1:
y = x[:-1]
texto.append(y)
return(texto)
except:
return(False)
def abrir_arch(self, arch):
try:
self.app_thread = LanzarArchivos()
self.app_thread.comando = arch
self.app_thread.start()
except:
return(False)
\ No newline at end of file \ No newline at end of file
HGT = {"nombre": "HGT", "CARPETA": "/home/juan/.hgt", "SSHprox":"3456",
"HOME": "https://play.google.com/apps/publish/", "SSHport":"4200", "SSHdom":"s2.hgtec.com.ar",
"SSHuser":"juan", "SSHpass":"xvc7733455"}
Remoto = {"nombre": "Remoto", "CARPETA": "/home/juan/.cromes/remoto", "SSHprox":"3457",
"HOME": "https://nextcloud.anacsoft.com", "SSHport":"4200", "SSHdom":"s2.hgtec.com.ar",
"SSHuser":"juan", "SSHpass":"xvc7733455"}
Personal = {"nombre": "Personal", "CARPETA": "/home/juan/.cromes/personal"}
nabegadores = [HGT, Remoto, Personal]
\ No newline at end of file \ No newline at end of file
import sys
import configuracion as config
import archivos
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtGui import QIcon
class App(QWidget):
def __init__(self):
super().__init__()
self.title = 'PyQt5 button - pythonspot.com'
self.left = 10
self.top = 10
self.width = 120
self.height = 200
self.ordenV = 0
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.show()
self.GenerarBotones()
def GenerarBotones(self):
n = 0
for conf in config.nabegadores:
self.constructor(conf["nombre"], n)
n += 1
def button_pushed(self, id):
nab = config.nabegadores[id]
try:
comando = "bash Proxy.sh {} {} {} {} {}".format(nab["SSHpass"],
nab["SSHuser"], nab["SSHport"], nab["SSHprox"], nab["SSHdom"])
except:
comando = "google-chrome"
comando = "{} --user-data-dir={}".format(comando, nab["CARPETA"])
try:
comando = "{} {}".format(comando, nab["HOME"])
except:
pass
print(comando)
archivos.ejecutar(self, comando)
def constructor(self, name, id):
self.ordenV += 25
button1 = QPushButton(str(name), self)
button1.move(10, self.ordenV)
button1.clicked.connect(lambda x:self.button_pushed(id))
button1.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!