-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring files in order to generate a .exe file
- Loading branch information
matheuslab
committed
Aug 21, 2021
1 parent
396b376
commit 795e751
Showing
10 changed files
with
109 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
venv/ | ||
__pycache__ | ||
.env | ||
output/main_file.py | ||
build/ | ||
dist/ | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
|
||
|
||
block_cipher = None | ||
|
||
|
||
a = Analysis(['src\\main.py'], | ||
pathex=['C:\\Users\\Matheus\\Pictures\\cobli-bi'], | ||
binaries=[], | ||
datas=[], | ||
hiddenimports=[], | ||
hookspath=[], | ||
hooksconfig={}, | ||
runtime_hooks=[], | ||
excludes=[], | ||
win_no_prefer_redirects=False, | ||
win_private_assemblies=False, | ||
cipher=block_cipher, | ||
noarchive=False) | ||
pyz = PYZ(a.pure, a.zipped_data, | ||
cipher=block_cipher) | ||
|
||
exe = EXE(pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
[], | ||
name='main', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
runtime_tmpdir=None, | ||
console=True, | ||
disable_windowed_traceback=False, | ||
target_arch=None, | ||
codesign_identity=None, | ||
entitlements_file=None ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import inspect | ||
import requests | ||
from productivity import getProductivityDataFrame, productivity_function_name | ||
from costs import getCostsDataFrame, costs_function_name | ||
from incidents import getIncidentsDataFrame, incidents_function_name | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
productivityScript = inspect.getsource(getProductivityDataFrame) | ||
costsScript = inspect.getsource(getCostsDataFrame) | ||
incidentsScript = inspect.getsource(getIncidentsDataFrame) | ||
|
||
with open("../output/data.py", "r") as dataFile: | ||
apiKeyList = dataFile.read() or os.getenv('API_KEY') | ||
parsedApiKeyList = apiKeyList.replace(' ', '').split(',') | ||
|
||
os.remove("../output/data.py") | ||
|
||
with open("../src/initial.py", "r") as initialFile, \ | ||
open('../output/main_file.py', 'w') as main_file: | ||
main_file.write(initialFile.read() + '\n\n') | ||
main_file.write(costsScript + '\n') | ||
main_file.write(incidentsScript + '\n') | ||
main_file.write(productivityScript + '\n') | ||
for key in parsedApiKeyList: | ||
response = requests.get('https://api.cobli.co/api-keys/external-auth', headers={'cobli-api-key': key}) | ||
|
||
if(response.status_code != 200): | ||
print(f"Algo de errado aconteceu na coleta de dados da API, usando a chave {key} \n\n") | ||
input("Pressione uma tecla para continuar!") | ||
exit() | ||
|
||
fleetId = response.headers.get('cobli-fleet-id').replace('.', '_').replace('-', '_') | ||
main_file.write( | ||
f"costsFunction_{fleetId} = {costs_function_name}('{key}')\n\n") | ||
main_file.write( | ||
f"incidentsFunction_{fleetId} = {incidents_function_name}('{key}')\n\n") | ||
main_file.write( | ||
f"productivityFunction_{fleetId} = {productivity_function_name}('{key}')\n\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
import platform | ||
from shutil import which | ||
|
||
if platform.system() == "Windows" and which("python") is None: | ||
if not os.path.isfile('./python.exe'): | ||
print("Fazendo download do Python") | ||
os.system("curl https://www.python.org/ftp/python/3.9.6/python-3.9.6-amd64.exe -o python.exe --silent") | ||
print("Instalando Python no seu computador...") | ||
os.system(".\python.exe /passive") | ||
os.system("pip install -q pandas matplotlib requests openpyxl") | ||
|
||
apiKeyList = input('Por favor, digite as chaves de API das frotas desejadas, separadas por vírgula: \n\n') | ||
|
||
with open("../output/data.py", "w") as dataFile: | ||
dataFile.write(apiKeyList) | ||
|
||
os.system("python ../src/generate_bi_script.py") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.