Beispiel #1
0
 def cxfreeze_build(source_name, source_folder, working_dir, project_name, build_target, includes_folder, setup_file, buttons_to_disable, cur_self):
     try:
         for button in buttons_to_disable:
             button.setDisabled(True)
         
         #Создаем временную папку по пути working_dir и компилируем в ней проект
         os.chdir(working_dir)
         shutil.rmtree('tmp2', ignore_errors=True)
         try:
             shutil.copytree(source_folder, 'tmp2')
         except Exception:
             shutil.rmtree('tmp2', ignore_errors=True)
             shutil.copytree(source_folder, 'tmp2')
         os.chdir('tmp2')
         shutil.copyfile(setup_file, 'setup.py')
         path = os.getcwd()
         command = str(sys.executable) + ' setup.py build'
     
     except Exception:
         Message.errorMessage(cur_self, ' ', 'Unknown error ocurred.\nYou can try to restart application.', os.path.join(working_dir, 'Resources', 'empt.ico'))
         os.chdir(working_dir)
         shutil.rmtree('tmp2', ignore_errors=True)
         for button in buttons_to_disable:
             button.setDisabled(False)
         return
     
     
     #Исполняем команду компиляции, выводя логи в QTextEdit
     cur_self.log = BuildLog(command, Builder._cxfreeze_continue, working_dir, buttons_to_disable,
                    [source_name, source_folder, working_dir, project_name, build_target, includes_folder, setup_file, buttons_to_disable, cur_self, path])
Beispiel #2
0
 def readStdError(self):
     try:
         self.edit.append(
             bytes(
                 self.buildProcess.readAllStandardError()).decode('utf-8'))
     except Exception:
         Message.errorMessage(
             self, ' ',
             'Unknown error ocurred.\nYou can try to restart application.')
 def openInIdle(current_self, fullsource):
     python = os.path.dirname(sys.executable)
     idle = os.path.join(python, "Lib", "idlelib") #Директория с idle
     
     if os.path.isdir(idle):
         if 'idle.bat' in os.listdir(idle):
             idle = os.path.join(idle, 'idle.bat')
             
             try: 
                 command = idle + (' "%s"' % fullsource)
                 result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Что-то типа:  ...\\idle.bat ...\\(source).py
                 time.sleep(IdleOpener.sleepTime) #Ждем sleepTime и проверяем, смог ли запуститься процесс
                 if result.poll(): #result.poll() - процесс не работает
                     Message.errorMessage(current_self, "Fail", "Failed to open IDLE") 
             except Exception:
                 pass
             
         elif 'idle.py' in os.listdir(idle):
             idle = os.path.join(idle, 'idle.py')
             
             try:
                 command = idle + (' "%s"' % fullsource)
                 result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Что-то типа:  ...\\idle.py ...\\(source).py
                 time.sleep(IdleOpener.sleepTime)
                 if result.poll():
                     Message.errorMessage(current_self, "Fail", "Failed to open IDLE") 
             except Exception:
                 pass
         else:
             try:
                 command = 'idle3' + (' "%s"' % fullsource)
                 result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
                 time.sleep(IdleOpener.sleepTime)
                 if result.poll():
                     try:
                         command = 'idle' + (' "%s"' % fullsource)
                         result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
                         time.sleep(IdleOpener.sleepTime)
                         if result.poll():
                             Message.errorMessage(current_self, "Fail", "Failed to open IDLE") 
                     except Exception:
                         pass
             except Exception:
                 pass
     else:
         try:
             command = 'idle3' + (' "%s"' % fullsource)
             result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
             time.sleep(IdleOpener.sleepTime)
             if result.poll():
                 try:
                     command = 'idle' + (' "%s"' % fullsource)
                     result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
                     time.sleep(IdleOpener.sleepTime)
                     if result.poll():
                         Message.errorMessage(current_self, "Fail", "Failed to open IDLE")
                 except Exception:
                     pass
         except Exception:
             pass