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")#нахождения расположения иконки.
- os.system(str('pyinstaller --onefile '+ py_scrypt))# сборка в exe файл.
- adress=str(os.getcwd()+"/dist")# директория с exe файлом.
- py_scrypt= os.path.basename(py_scrypt)# получить имя скрипта.
- name_file=py_scrypt[:-3]#.replace("\\","")
- home=str(os.getcwd()) #
- adress=str(adress+"/"+name_file).replace('\\','') # расположения exe файла.
- shutil.move(adress, os.getcwd())# переместить файл в новую директорию.
- shutil.rmtree(home+'/dist')
- shutil.rmtree(home+'/build')
- script = '''#!/bin/bash
- gnome-terminal -- bash -c ' chmod +x $i
- done
- exit'
- '''
- subprocess.call(['bash', '-c', script])
- name_file=name_file.replace("\\","")
- os.remove(os.getcwd()+'/'+name_file+'.spec')
- s=str("#!/bin/bash \n"
- # Переход в текущую директорию
- "cd $(dirname $0)\n"
- "./{0}"
- ).format(name_file)
- name_file = str(name_file+".sh")
- with open(name_file,"w") as f:
- f.write(s)
- script = '''#!/bin/bash
- gnome-terminal -- bash -c ' chmod +x name_file
- done
- exit'
- '''
- subprocess.call(['bash', '-c', script])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement