Skip to content

Commit 0b5b6bb

Browse files
committed
rodado black
1 parent 531b4fe commit 0b5b6bb

File tree

7 files changed

+210
-123
lines changed

7 files changed

+210
-123
lines changed

config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
2-
class Config():
32

3+
4+
class Config:
45
def __init__(self):
56

67
self.diretorioarcom = "c:\\Arcom"
@@ -14,10 +15,10 @@ def __init__(self):
1415
hostAndPort=false
1516
DisableHostnameVerification=true
1617
"""
17-
18+
1819
self.allusersdesktop = r"c:\Users\Public\Desktop"
1920
self.userdesktop = r"%USERPROFILE%\Desktop"
2021

2122
def criardiretorio(self, diretorio):
2223
if not os.path.exists(diretorio):
23-
os.mkdir(diretorio)
24+
os.mkdir(diretorio)

configuracao.py

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@
33
import os
44
from object_execute import Object_execute
55

6-
class Dominio():
6+
7+
class Dominio:
78
def __init__(self):
89
self.descricao = "Domínio:"
9-
self.definicao = 'dominio'
10+
self.definicao = "dominio"
1011
self.valor = ""
1112

1213

13-
class Usuario():
14+
class Usuario:
1415
def __init__(self):
1516
self.descricao = "Usuario:"
16-
self.definicao = 'usuario'
17+
self.definicao = "usuario"
1718
self.valor = ""
1819

1920

20-
class Senha():
21+
class Senha:
2122
def __init__(self):
2223
self.descricao = "Senha:"
23-
self.definicao = 'senha'
24+
self.definicao = "senha"
2425
self.valor = ""
2526

2627

@@ -43,41 +44,82 @@ def change_gui(self, window, values):
4344
self.window = window
4445
self.values = values
4546
estado = self.values[self.definicao]
46-
window[self.dominio.definicao].update(
47-
disabled=not estado)
48-
window[self.usuario.definicao].update(
49-
disabled=not estado)
50-
window[self.senha.definicao].update(
51-
disabled=not estado)
47+
window[self.dominio.definicao].update(disabled=not estado)
48+
window[self.usuario.definicao].update(disabled=not estado)
49+
window[self.senha.definicao].update(disabled=not estado)
5250

5351
def gui(self):
5452
dominio = [
55-
[sg.Checkbox(self.descricao,
56-
key=self.definicao, size=(24, 1), enable_events=True)],
57-
[sg.Text(self.dominio.descricao, justification='left', size=(9, 1)), sg.Input(
58-
'', key=self.dominio.definicao, background_color='white', border_width=1, justification='left', size=(15, 1), disabled=True)],
59-
[sg.Text(self.usuario.descricao, justification='left', size=(9, 1)), sg.Input(
60-
'', key=self.usuario.definicao, background_color='white', border_width=1, justification='left', size=(15, 1), disabled=True)],
61-
[sg.Text(self.senha.descricao, justification='left', size=(9, 1)), sg.Input(
62-
'', key=self.senha.definicao, password_char='*', background_color='white', border_width=1, justification='left', size=(15, 1), disabled=True)],
63-
[sg.Input("",key=self.definicao + "status", background_color="White", border_width=1, justification='left', disabled=True, size=(30, 1)),]
53+
[
54+
sg.Checkbox(
55+
self.descricao, key=self.definicao, size=(24, 1), enable_events=True
56+
)
57+
],
58+
[
59+
sg.Text(self.dominio.descricao, justification="left", size=(9, 1)),
60+
sg.Input(
61+
"",
62+
key=self.dominio.definicao,
63+
background_color="white",
64+
border_width=1,
65+
justification="left",
66+
size=(15, 1),
67+
disabled=True,
68+
),
69+
],
70+
[
71+
sg.Text(self.usuario.descricao, justification="left", size=(9, 1)),
72+
sg.Input(
73+
"",
74+
key=self.usuario.definicao,
75+
background_color="white",
76+
border_width=1,
77+
justification="left",
78+
size=(15, 1),
79+
disabled=True,
80+
),
81+
],
82+
[
83+
sg.Text(self.senha.descricao, justification="left", size=(9, 1)),
84+
sg.Input(
85+
"",
86+
key=self.senha.definicao,
87+
password_char="*",
88+
background_color="white",
89+
border_width=1,
90+
justification="left",
91+
size=(15, 1),
92+
disabled=True,
93+
),
94+
],
95+
[
96+
sg.Input(
97+
"",
98+
key=self.definicao + "status",
99+
background_color="White",
100+
border_width=1,
101+
justification="left",
102+
disabled=True,
103+
size=(30, 1),
104+
),
105+
],
64106
]
65-
return [sg.Frame('Domínio:', dominio, font='Any 12', title_color='black')]
107+
return [sg.Frame("Domínio:", dominio, font="Any 12", title_color="black")]
66108

67109

68110
class Citrixcleanup(Object_execute):
69-
70111
def define_param(self):
71112
self.descricao = "Limpar registro do Citrix"
72113
self.definicao = "citrixcleanup"
73114

74115
def thread_configurar(self):
75116
self.reportar("Removendo registro")
76-
self.executar("reg delete HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSLicensing /f")
117+
self.executar(
118+
"reg delete HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSLicensing /f"
119+
)
77120

78121

79122
class Limpezageral(Object_execute):
80-
81123
def define_param(self):
82124
self.descricao = "Limpar diretório Arcom"
83125
self.definicao = "limpezageral"
@@ -89,7 +131,6 @@ def thread_configurar(self):
89131

90132

91133
class Reniciar(Object_execute):
92-
93134
def define_param(self):
94135
self.descricao = "Reniciar cpu após execução"
95136
self.definicao = "reniciar"
@@ -100,7 +141,6 @@ def thread_configurar(self):
100141

101142

102143
class OpenvpnStart(Object_execute):
103-
104144
def define_param(self):
105145
self.descricao = "Ativar openvpn"
106146
self.definicao = "openvpnstart"
@@ -112,7 +152,6 @@ def thread_configurar(self):
112152

113153

114154
class OpenvpnStop(Object_execute):
115-
116155
def define_param(self):
117156
self.descricao = "Desativar openvpn"
118157
self.definicao = "openvpnstop"

functions.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import subprocess
32
import requests
43
import os
@@ -8,33 +7,41 @@
87
import logging
98
from config import Config
109

11-
class Functions(Config):
1210

11+
class Functions(Config):
1312
def __init__(self):
1413
super().__init__()
15-
logging.basicConfig(filename=self.diretorioarcom + "\\INSTALL_COOPS.log",
16-
filemode='a',
17-
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
18-
datefmt='%H:%M:%S',
19-
level=logging.DEBUG)
14+
logging.basicConfig(
15+
filename=self.diretorioarcom + "\\INSTALL_COOPS.log",
16+
filemode="a",
17+
format="%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s",
18+
datefmt="%H:%M:%S",
19+
level=logging.DEBUG,
20+
)
2021
self.logger = logging
2122

22-
2323
# Super classe para funcao de report
24-
def reportar(self,msg):
24+
def reportar(self, msg):
2525
self.logger.debug(msg)
2626

2727
# Execucao de aplicativos e scripts
28-
def executar(self,command):
28+
def executar(self, command):
2929
startupinfo = subprocess.STARTUPINFO()
3030
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
31-
process = subprocess.Popen(command, cwd=self.diretorioarcom, startupinfo=startupinfo, stdout=subprocess.PIPE,
32-
stderr=subprocess.PIPE, stdin=subprocess.DEVNULL, shell=True)
31+
process = subprocess.Popen(
32+
command,
33+
cwd=self.diretorioarcom,
34+
startupinfo=startupinfo,
35+
stdout=subprocess.PIPE,
36+
stderr=subprocess.PIPE,
37+
stdin=subprocess.DEVNULL,
38+
shell=True,
39+
)
3340
result, error = process.communicate()
3441
exitCode = process.wait()
3542
errortext = error.decode("cp1252")
3643
if exitCode > 0:
37-
if(str(error) == ""):
44+
if str(error) == "":
3845
error = result
3946
self.reportar("Code: " + str(exitCode) + " - Message: " + errortext)
4047
else:
@@ -43,26 +50,27 @@ def executar(self,command):
4350
# Adicionar no domínio
4451
def addtodomain(self, dominio, usuario, senha):
4552
self.executar(
46-
f'@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command \"$domain = "{dominio}"; $password = "{senha}" | ConvertTo-SecureString -asPlainText -Force; $username = \'{usuario}@$domain\';$credential = New-Object System.Management.Automation.PSCredential($username,$password);Add-Computer -DomainName $domain -Credential $credential\"')
47-
53+
f'@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "$domain = "{dominio}"; $password = "{senha}" | ConvertTo-SecureString -asPlainText -Force; $username = \'{usuario}@$domain\';$credential = New-Object System.Management.Automation.PSCredential($username,$password);Add-Computer -DomainName $domain -Credential $credential"'
54+
)
4855

4956
# Executa instalacao de programas
5057
def installprograma(self, diretorioarcom, programa):
5158
if not os.path.isfile(self.chocolateypath):
5259
self.reportar("Executando instalação do chocolatey")
5360
self.executar(
54-
'@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"')
55-
self.executar(self.chocolateypath + " config set cacheLocation " + diretorioarcom)
61+
'@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"'
62+
)
63+
self.executar(
64+
self.chocolateypath + " config set cacheLocation " + diretorioarcom
65+
)
5666
self.reportar("Executando instalação, " + programa)
5767
self.executar(self.chocolateypath + " install -y " + programa)
5868

59-
6069
# Baixa arquivos do google drive
6170
def download_file_from_google_drive(self, id, destination):
62-
6371
def get_confirm_token(response):
6472
for key, value in response.cookies.items():
65-
if key.startswith('download_warning'):
73+
if key.startswith("download_warning"):
6674
return value
6775
return None
6876

@@ -78,11 +86,11 @@ def save_response_content(response, destination):
7886

7987
session = requests.Session()
8088

81-
response = session.get(URL, params={'id': id}, stream=True)
89+
response = session.get(URL, params={"id": id}, stream=True)
8290
token = get_confirm_token(response)
8391

8492
if token:
85-
params = {'id': id, 'confirm': token}
93+
params = {"id": id, "confirm": token}
8694
response = session.get(URL, params=params, stream=True)
8795

8896
save_response_content(response, destination)

0 commit comments

Comments
 (0)