Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, time, shutil, subprocess, glob
- from PIL import Image
- def find_image():
- t=['*.png', '*.jpg','*.jpeg','*.bmp']
- number=0
- for i in t:
- i2=str(i)
- for file in glob.glob(i2):
- adress=os.path.join(os.getcwd(), file).lstrip('\u202a')
- return adress
- return
- def convert_to_ico(input_path):
- if input_path != '':
- image = Image.open(input_path)
- # output_path=adress[:-3]+'ico'
- # image.save(output_path, format='ico')
- def find_file(type):
- adress_to_file=""
- adress=str(os.getcwd())
- for root, dirs, files in os.walk(adress):
- for file in files:
- if file.endswith(type) and file !='con_in_bin.py':
- adress_to_file=os.path.join(root, file)
- adress_to_file=adress_to_file.replace(" ", "\ ")
- break
- return adress_to_file
- # adress = find_image()
- # convert_to_ico(adress)
- py_scrypt= find_file("py")# нахождения расположения скрипта.
- # adress_icon= find_file("ico")#нахождения расположения иконки.
- home=str(os.getcwd()) #
- os.system(str('pyinstaller --onefile '+ py_scrypt))# сборка в exe файл.
- py_scrypt= os.path.basename(py_scrypt)# получить имя скрипта.
- name_file=py_scrypt[:-3]#.replace("\\","")
- adress=str(os.getcwd()+"/dist/"+name_file).replace('\\','') # расположение директории с исполяемым файлом.
- script = f'''#!/bin/bash
- name="{name_file}"
- gnome-terminal -- bash -c 'chmod +x "$name"; done; exit'
- '''
- subprocess.call(['bash', '-c', script])
- parent_dir = str(os.path.dirname(home))
- # print(adress)
- # print(parent_dir)
- # print(name_file)
- script = ("#!/bin/bash\n"
- "gnome-terminal -- bash -c \'cd \"{0}\";\n"
- "./{1};\n"
- "exit;\n"
- "exec bash\'".format(parent_dir,name_file))
- # print(parent_dir)
- # print(script)
- parent_dir=str(parent_dir+"/"+name_file).replace('\\','') # расположения exe файла.
- with open(str(parent_dir)+".sh",'w') as f:
- f.write(script)
- shutil.move(adress, parent_dir)# переместить файл в новую директорию.
- shutil.rmtree(home+'/dist')
- shutil.rmtree(home+'/build')
- name_file1=name_file.replace("\\","")
- os.remove(os.getcwd()+'/'+name_file1+'.spec')
- name_file=name_file1.replace(" ", "_")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement