def initialize(self):
     defaults = settings.SettingsClass().load()
     #
     app_folder = os.path.dirname(os.path.abspath(__file__))
     imageMagickPath = os.path.join(app_folder, 'ImageMagick', 'magick.exe')
     self.imagemagick_lb.setText(imageMagickPath)
     #
     includeSubfoldersFlag = defaults.get('IncludeSubfoldersFlag')
     if includeSubfoldersFlag:
         self.subfolders_chb.setChecked(True)
     else:
         self.subfolders_chb.setChecked(False)
     #
     destinationFolder = defaults.get('DestinationFolder')
     if destinationFolder:
         self.out_le.setText(destinationFolder)
     #
     nameCollisionResolutionPolicy = defaults.get(
         'NameCollisionResolutionPolicy')
     if nameCollisionResolutionPolicy == 'Skip':
         self.skip_rbtn.setChecked(True)
     else:
         self.replace_rbtn.setChecked(True)
     #
     destinationFormat = defaults.get('DestinationFormat')
     supportedFormats = []
     for item in range(0, self.formatOut_cbox.count()):
         fileformat = self.formatOut_cbox.itemText(item)
         supportedFormats.append(fileformat)
     if destinationFormat in supportedFormats:
         index = self.formatOut_cbox.findText(destinationFormat)
         self.formatOut_cbox.setCurrentIndex(index)
示例#2
0
 def open_settings_dialog(self):
     # Modal window
     self.dial = settingsDialog.SettingsDialogClass(self)
     if self.dial.exec_():
         data = self.dial.get_table_data()
         settings.SettingsClass().save(data)
     self.update_list()
示例#3
0
 def openFolder(self, folder):
     try:
         path = settings.SettingsClass().load()[folder]
         if not os.path.exists(path):
             os.mkdir(path)
         webbrowser.open(path)
     except KeyError:
         pass
示例#4
0
def createProject(data):
    template = json.load(open(templateEditor.templateFile))
    path = settings.SettingsClass().load()['path']
    if os.path.exists(path):
        pName = checkLegalCharacters(data['name'])
        pPath = os.path.join(path, pName)
        if mkFolder(pPath):
            buildFolders(pPath, template)
        makeProjectFile(pPath, data)
示例#5
0
 def backupProject(self, item):
     if not item:
         return None
     old_path = item.data(32)
     project_name = os.path.split(old_path)[-1]
     current_time = time.strftime('%Y-%m-%d_%H-%M-%S')
     backup_folder = settings.SettingsClass().load()['backup']
     new_path = os.path.join(backup_folder, project_name, current_time)
     zipfolder.zipFolder(old_path, new_path)
     self.update_list()
示例#6
0
def zipFolder(old_path, new_path):
    if sys.platform == 'win32':
        win_encoding = settings.SettingsClass().load()['winEncoding']
        archiver_folder = os.path.dirname(os.path.abspath(__file__))
        archiver = os.path.join(archiver_folder, '7zr.exe')
        archive_name = (new_path + '.7z')
        command = r'"{0}" a -bd -y "{1}" "{2}"'.format(archiver, archive_name,
                                                       old_path)
        subprocess.call(command.encode(win_encoding))
    else:
        shutil.make_archive(new_path, 'zip', old_path)
示例#7
0
 def update_project_list(self):
     self.clear()
     data = settings.SettingsClass().load()
     path = data.get('path')
     if path:
         if os.path.exists(path):
             for f in os.listdir(path):
                 fullPath = os.path.join(path, f)
                 if self.isProject(fullPath):
                     item = self.addProject(f)
                     item.setData(32, fullPath)
         return True
     else:
         return False
示例#8
0
 def dropEvent(self, event):
     """Copy dropped folders as projects"""
     mimedata = event.mimeData()
     if mimedata.hasUrls():
         for url in mimedata.urls():
             orig_path = url.toLocalFile()
             if os.path.isdir(orig_path):
                 # Copy folder
                 folder_name = os.path.basename(orig_path)
                 project_folder = settings.SettingsClass().load()['path']
                 new_path = os.path.join(project_folder, folder_name)
                 if not os.path.exists(new_path):
                     shutil.copytree(orig_path, new_path)
                     project_data = dict(name=folder_name, comment='')
                     createProject.makeProjectFile(new_path, project_data)
     self.update_list()
示例#9
0
 def archiveProject(self, item):
     if not item:
         return None
     old_path = item.data(32)
     project_name = os.path.split(old_path)[-1]
     archive_folder = settings.SettingsClass().load()['archive']
     new_path = os.path.join(archive_folder, project_name)
     if os.path.exists(new_path):
         message = QMessageBox()
         message.setWindowTitle('Cannot Move to Archive')
         message.setText(
             'There is a project named "{0}" in the archive.\nPlease, rename the project and try again.'
             .format(project_name))
         message.exec_()
     else:
         shutil.move(old_path, new_path)
     self.update_list()
示例#10
0
 def fill_table(self):
     data = settings.SettingsClass().load()
     for key, value in data.items():
         self.add_parm(key, value)
示例#11
0
 def save_settings(self, key, value):
     data = settings.SettingsClass().load()
     data[key] = value
     settings.SettingsClass().save(data)