Exemplo n.º 1
0
    def index_path():
        options = Configuration._read_options(
            config_file=Configuration.INDEXING_CONFIG_FILE,
            config_file_header=Configuration.INDEXING_CONFIG_FILE_HEADER
        )

        if Configuration.INDEXING_CONFIG_PATH in options:
            return QDir.fromNativeSeparators(options[Configuration.INDEXING_CONFIG_PATH])

        return QDir.fromNativeSeparators('%s/%s' % (QDir.homePath(), 'index_db'))
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(StartPage, self).__init__(parent)
        self._id = "Start Page"
        vbox = QVBoxLayout(self)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(430)
        #self.view.setMinimumWidth(400)
        #self.view.setMinimumHeight(500)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        path_qml = QDir.fromNativeSeparators(
            os.path.join(resources.QML_FILES, "StartPage_Alexa.qml"))
            #os.path.join(resources.QML_FILES, "StartPage.qml"))
        path_qml = urlunparse(urlparse(path_qml)._replace(scheme='file'))
        self.view.setSource(QUrl(path_qml))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)

        self.load_items()

        self.connect(self.root, SIGNAL("openProject(QString)"),
            self._open_project)
        self.connect(self.root, SIGNAL("removeProject(QString)"),
            self._on_click_on_delete)
        self.connect(self.root, SIGNAL("markAsFavorite(QString, bool)"),
            self._on_click_on_favorite)
        self.connect(self.root, SIGNAL("openPreferences()"),
            lambda: self.emit(SIGNAL("openPreferences()")))
Exemplo n.º 3
0
class AudiotoolsTestCase(unittest.TestCase):

    testPath = unicode(QDir.fromNativeSeparators(os.path.dirname(__file__)))
    showPath = testPath + '/test-shows'

    antiCrashBin = []
    """PCMReader objects going out of scope causes Windows 7 to crash, hence the antiCrashBin"""

    def tearDown(self):
        outputDir = QDir(self.testPath + '/output')
        outputDir.setNameFilters(['*.m4a'])
        for outputFile in outputDir.entryList():
            outputDir.remove(outputFile)            

    def testFlacConversion(self):
        audioFile = audiotools.open(self.showPath + '/show1/1.flac')
        pcmReader = audioFile.to_pcm()
        self.antiCrashBin.append(pcmReader)        
        alacFile = audiotools.ALACAudio.from_pcm(self.testPath + '/output/1.m4a', pcmReader)
        self.assertTrue(os.path.exists(self.testPath + '/output/1.m4a'))
        pass
    
    def testShnConversion(self):
        audioFile = audiotools.open(self.showPath + '/show2/CD1/1.shn')
        pcmReader = audioFile.to_pcm()
        self.antiCrashBin.append(pcmReader)
        alacFile = audiotools.ALACAudio.from_pcm(self.testPath + '/output/2.m4a', pcmReader)
        self.assertTrue(os.path.exists(self.testPath + '/output/2.m4a'))
        pass
Exemplo n.º 4
0
    def run_compilation(self, sources):
        """ Se corre el comando gcc para la compilación """

        # Ejecutable
        filename, files = sources
        if not files:
            # No es un proyecto
            files = [filename]
        path = QDir.fromNativeSeparators(filename)
        self.exe = os.path.splitext(os.path.basename(path))[0]

        # Generar el ejecutable en el directorio del código fuente
        exe_path = os.path.dirname(path)
        self.build_process.setWorkingDirectory(exe_path)

        # Se limpia el QListWidget
        self.output.clear()

        flags = settings.COMPILER_FLAGS.split()
        params = ['-o', self.exe] + flags
        gcc = 'gcc'
        if not sys.platform.startswith("linux"):
            gcc = os.path.join(self._environment, 'gcc')

        item = output_compiler.Item(
            self.tr(">>> Compilando: {0} ( en directorio {1} )").format(
                    path.split('/')[-1], exe_path))
        self.output.addItem(item)
        self.output.addItem(output_compiler.Item(
            self.tr(">>> Comando: {0}").format(
                gcc + ' ' + ' '.join(params) + ' ' + ' '.join(files))))

        # Se inicia el proceso
        self.build_process.start(gcc, params + files)
        self.build_process.waitForFinished()
def fromNativeSeparators(path):
    """
    Function returning a path, that is using "/" separator characters.
    
    @param path path to be converted (QString)
    @return path with converted separator characters (QString)
    """
    return QDir.fromNativeSeparators(path)
Exemplo n.º 6
0
    def _set_selected_directory(self, txt_box, title):
        def_path = txt_box.text()
        sel_doc_path = QFileDialog.getExistingDirectory(self, title, def_path)

        if sel_doc_path:
            normalized_path = QDir.fromNativeSeparators(sel_doc_path)
            txt_box.clear()
            txt_box.setText(normalized_path)
Exemplo n.º 7
0
def fromNativeSeparators(path):
    """
    Function returning a path, that is using "/" separator characters.
    
    @param path path to be converted (QString)
    @return path with converted separator characters (QString)
    """
    return QDir.fromNativeSeparators(path)
Exemplo n.º 8
0
    def _set_selected_directory(self, txt_box, title):
        def_path= txt_box.text()
        sel_doc_path = QFileDialog.getExistingDirectory(self, title, def_path)

        if sel_doc_path:
            normalized_path = QDir.fromNativeSeparators(sel_doc_path)
            txt_box.clear()
            txt_box.setText(normalized_path)
Exemplo n.º 9
0
 def __init__(self):
     super(StartPage, self).__init__()
     vbox = QVBoxLayout(self)
     vbox.setContentsMargins(0, 0, 0, 0)
     view = QDeclarativeView()
     qml = os.path.join(os.path.dirname(__file__), "StartPage.qml")
     path = QDir.fromNativeSeparators(qml)
     view.setSource(QUrl.fromLocalFile(path))
     view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
     self._root = view.rootObject()
     vbox.addWidget(view)
Exemplo n.º 10
0
    def show_add_directory_dialog(self):
        directory = get_existing_directory(get_main_window(), 'Add Directory',
                                           self.last_directory)

        if len(directory) == 0:
            return

        self.last_directory = directory

        if len(
                self.list_files.findItems(os.path.join(directory, '*'),
                                          Qt.MatchFixedString)) > 0:
            return

        uploads = []

        progress = ExpandingProgressDialog(self)
        progress.set_progress_text_visible(False)
        progress.setWindowTitle('New Program')
        progress.setLabelText(u"Collecting content of {0}".format(directory))
        progress.setModal(True)
        progress.setRange(0, 0)
        progress.show()

        for root, directories, files in os.walk(directory):
            if progress.wasCanceled():
                break

            for filename in files:
                source = os.path.join(root, filename)
                target = QDir.fromNativeSeparators(
                    os.path.relpath(source, directory))
                uploads.append(Upload(source, target))

                # ensure that the UI stays responsive
                QApplication.processEvents()

                if progress.wasCanceled():
                    break

        if progress.wasCanceled():
            return

        progress.cancel()

        # FIXME: maybe add a warning if the directory contains very many files or large amounts of data

        item = QListWidgetItem(os.path.join(directory, '*'))
        item.setData(Qt.UserRole, uploads)
        item.setData(Qt.DecorationRole, self.folder_icon)
        self.list_files.addItem(item)

        self.completeChanged.emit()
Exemplo n.º 11
0
    def show_add_directory_dialog(self):
        directory = get_existing_directory(get_main_window(), 'Add Directory', self.last_directory)

        if len(directory) == 0:
            return

        self.last_directory = directory

        if len(self.list_files.findItems(os.path.join(directory, '*'), Qt.MatchFixedString)) > 0:
            return

        uploads = []

        progress = ExpandingProgressDialog(self)
        progress.set_progress_text_visible(False)
        progress.setWindowTitle('New Program')
        progress.setLabelText(u"Collecting content of {0}".format(directory))
        progress.setModal(True)
        progress.setRange(0, 0)
        progress.show()

        for root, directories, files in os.walk(directory):
            if progress.wasCanceled():
                break

            for filename in files:
                source = os.path.join(root, filename)
                target = QDir.fromNativeSeparators(os.path.relpath(source, directory))
                uploads.append(Upload(source, target))

                # ensure that the UI stays responsive
                QApplication.processEvents()

                if progress.wasCanceled():
                    break

        if progress.wasCanceled():
            return

        progress.cancel()

        # FIXME: maybe add a warning if the directory contains very many files or large amounts of data

        item = QListWidgetItem(os.path.join(directory, '*'))
        item.setData(Qt.UserRole, uploads)
        item.setData(Qt.DecorationRole, self.folder_icon)
        self.list_files.addItem(item)

        self.completeChanged.emit()
Exemplo n.º 12
0
    def _load_source_document_directory_selector(self):
        #Load file dialog for selecting source documents directory
        title = self.tr('Select Source Document Directory')
        def_path = self.txtRootFolder.text()

        #Use the last set source document directory
        if not def_path:
            def_path = last_document_path()

        sel_doc_path = QFileDialog.getExistingDirectory(self, title, def_path)

        if sel_doc_path:
            normalized_path = QDir.fromNativeSeparators(sel_doc_path)
            self.txtRootFolder.clear()
            self.txtRootFolder.setText(normalized_path)
Exemplo n.º 13
0
    def _load_source_document_directory_selector(self):
        #Load file dialog for selecting source documents directory
        title = self.tr('Select Source Document Directory')
        def_path = self.txtRootFolder.text()

        #Use the last set source document directory
        if not def_path:
            def_path = last_document_path()

        sel_doc_path = QFileDialog.getExistingDirectory(self, title, def_path)

        if sel_doc_path:
            normalized_path = QDir.fromNativeSeparators(sel_doc_path)
            self.txtRootFolder.clear()
            self.txtRootFolder.setText(normalized_path)
Exemplo n.º 14
0
    def __init__(self):
        QWidget.__init__(self)
        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 0, 0)
        view = QDeclarativeView()
        view.setMinimumSize(400, 400)
        qml = os.path.join(paths.PATH, "ui", "StartPage.qml")
        path = QDir.fromNativeSeparators(qml)
        view.setSource(QUrl.fromLocalFile(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self._root = view.rootObject()
        box.addWidget(view)

        self._current_text = ""
        # Timer
        self.timer = QTimer(self)
        self.timer.setInterval(3000)
        self._show_welcome_text()
        self.timer.timeout.connect(self._show_text)
        self.timer.start()
Exemplo n.º 15
0
    def __init__(self):
        QWidget.__init__(self)
        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 0, 0)
        view = QDeclarativeView()
        view.setMinimumSize(400, 400)
        qml = os.path.join(paths.PATH, "ui", "StartPage.qml")
        path = QDir.fromNativeSeparators(qml)
        view.setSource(QUrl.fromLocalFile(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self._root = view.rootObject()
        box.addWidget(view)

        self._current_text = ""
        # Timer
        self.timer = QTimer(self)
        self.timer.setInterval(3000)
        self._show_welcome_text()
        self.timer.timeout.connect(self._show_text)
        self.timer.start()
Exemplo n.º 16
0
    def correr_compilacion(self, nombre_archivo=''):
        """ Se corre el comando gcc para la compilación """

        # Ejecutable
        directorio = QDir.fromNativeSeparators(nombre_archivo)
        self.ejecutable = directorio.split('/')[-1].split('.')[0]

        # Generar el ejecutable en el directorio del código fuente
        directorio_ejecutable = os.path.dirname(directorio)
        self.proceso_compilacion.setWorkingDirectory(directorio_ejecutable)

        self.output.clear()
        item = salida.Item(self.tr(
                           "Compilando archivo: %s ( %s )" %
                           (directorio.split('/')[-1], nombre_archivo)))
        self.output.addItem(item)

        gcc = GCC
        parametros_gcc = ['-Wall', '-o']
        self.proceso_compilacion.start(gcc, parametros_gcc +
                                       [self.ejecutable] + [nombre_archivo])
        self.proceso_compilacion.waitForFinished()
Exemplo n.º 17
0
    def __init__(self, parent=None):
        super(Selector, self).__init__(parent,
                                       Qt.Dialog | Qt.FramelessWindowHint)
        # Configuración
        self.setModal(True)

        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 1, 1)
        box.setSpacing(0)
        # Interfáz QML
        view = QDeclarativeView()
        qml = os.path.join(paths.PATH, "ui", "selector", "selector.qml")
        path = QDir.fromNativeSeparators(qml)
        view.setSource(QUrl.fromLocalFile(path))

        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        box.addWidget(view)

        self.root = view.rootObject()
        self.__cargar()

        self.connect(self.root, SIGNAL("abrirArchivo(int)"),
                     self.__abrir_archivo)
Exemplo n.º 18
0
    def run_compilation(self, sources):
        """ Se corre el comando gcc para la compilación """

        # Ejecutable
        filename, files = sources
        if not files:
            # No es un proyecto
            files = [filename]
        path = QDir.fromNativeSeparators(filename)
        self.exe = os.path.splitext(os.path.basename(path))[0]

        # Generar el ejecutable en el directorio del código fuente
        exe_path = os.path.dirname(path)
        self.build_process.setWorkingDirectory(exe_path)

        # Se limpia el QListWidget
        self.output.clear()

        flags = settings.COMPILER_FLAGS.split()
        params = ['-o', self.exe] + flags
        gcc = 'gcc'
        if not sys.platform.startswith("linux"):
            gcc = os.path.join(self._environment, 'gcc')

        item = output_compiler.Item(
            self.tr(">>> Compilando: {0} ( en directorio {1} )").format(
                path.split('/')[-1], exe_path))
        self.output.addItem(item)
        self.output.addItem(
            output_compiler.Item(
                self.tr(">>> Comando: {0}").format(gcc + ' ' +
                                                   ' '.join(params) + ' ' +
                                                   ' '.join(files))))

        # Se inicia el proceso
        self.build_process.start(gcc, params + files)
        self.build_process.waitForFinished()
Exemplo n.º 19
0
def get_qml_resource(qmlpath):
    path_qml = QDir.fromNativeSeparators(
        os.path.join(resources.QML_FILES, qmlpath))
    path_qml = urlunparse(urlparse(path_qml)._replace(scheme='file'))
    return QUrl(path_qml)
Exemplo n.º 20
0
 def getProjectLocation(self):
     '''获取项目路径'''
     path = QFileDialog.getExistingDirectory()
     path = QDir.fromNativeSeparators(path)
     self.et_project_location.setText(path)
Exemplo n.º 21
0
class CoverArtRetrieverTestCase(unittest.TestCase):

    testPath = unicode(QDir.fromNativeSeparators(os.path.dirname(__file__)))
    showPath = testPath + '/test-shows'
    outputPath = testPath + '/output'

    metadata = {
        'tempDir': QDir(outputPath),
        'hash': md5('Any value here will do.').hexdigest()
    }
    """The value passed to the getCoverImageChoices method"""
    def setUp(self):
        self.settings = getSettings("test")
        self.app = QApplication(sys.argv)

    def tearDown(self):
        del self.settings
        del self.metadata['dir']
        del self.app
        outputDir = QDir(self.outputPath)
        outputDir.setFilter(QDir.Files)
        for file in outputDir.entryList():
            filePath = unicode(self.outputPath + '/' + file)
            os.unlink(filePath)

    def testIfNoImageFilesForShowIdenticonChoicesWillBeAvailable(self):
        self.settings['defaultArt'] = 'Visicon'
        self.metadata['dir'] = QDir(self.showPath + '/show1')
        choices = CoverArtRetriever.getCoverImageChoices(self.metadata)
        self.assertEquals(self.outputPath + '/visicon.png', choices[0][0])
        self.assertEquals(self.outputPath + '/identicon.png', choices[1][0])
        self.assertEquals(
            QPixmap(self.outputPath + '/visicon.png').cacheKey(),
            choices[0][1].cacheKey())
        self.assertEquals(
            QPixmap(self.outputPath + '/identicon.png').cacheKey(),
            choices[1][1].cacheKey())

    def testImagesFoundInTopLevelDirectoryOfShow(self):
        self.settings['defaultArt'] = 'Image File => Visicon'
        self.metadata['dir'] = QDir(self.showPath + '/show2')
        choices = CoverArtRetriever.getCoverImageChoices(self.metadata)
        self.assertEquals(self.showPath + '/show2/art.png', choices[0][0])
        self.assertEquals(self.showPath + '/show2/art.jpg', choices[1][0])
        self.assertEquals(self.showPath + '/show2/art.gif', choices[2][0])
        self.assertEquals(self.outputPath + '/visicon.png', choices[3][0])
        self.assertEquals(self.outputPath + '/identicon.png', choices[4][0])
        self.assertEquals(
            QPixmap(self.showPath + '/show2/art.png').cacheKey(),
            choices[0][1].cacheKey())
        self.assertEquals(
            QPixmap(self.showPath + '/show2/art.jpg').cacheKey(),
            choices[1][1].cacheKey())
        self.assertEquals(
            QPixmap(self.showPath + '/show2/art.gif').cacheKey(),
            choices[2][1].cacheKey())
        self.assertEquals(
            QPixmap(self.outputPath + '/visicon.png').cacheKey(),
            choices[3][1].cacheKey())
        self.assertEquals(
            QPixmap(self.outputPath + '/identicon.png').cacheKey(),
            choices[4][1].cacheKey())

    def testImagesFoundInSubFolders(self):
        self.settings['defaultArt'] = 'Image File => Visicon'
        self.metadata['dir'] = QDir(self.showPath + '/show3')
        choices = CoverArtRetriever.getCoverImageChoices(self.metadata)
        self.assertEquals(self.showPath + '/show3/artwork/art.png',
                          choices[0][0])
        self.assertEquals(self.outputPath + '/visicon.png', choices[1][0])
        self.assertEquals(self.outputPath + '/identicon.png', choices[2][0])
        self.assertEquals(
            QPixmap(self.showPath + '/show3/artwork/art.png').cacheKey(),
            choices[0][1].cacheKey())
        self.assertEquals(
            QPixmap(self.outputPath + '/visicon.png').cacheKey(),
            choices[1][1].cacheKey())
        self.assertEquals(
            QPixmap(self.outputPath + '/identicon.png').cacheKey(),
            choices[2][1].cacheKey())
Exemplo n.º 22
0
 def getProjectLocation(self):
     '''获取项目路径'''
     path = QFileDialog.getExistingDirectory()
     path = QDir.fromNativeSeparators(path)
     self.et_project_location.setText(path)
Exemplo n.º 23
0
def get_qml_resource(qmlpath):
    path_qml = QDir.fromNativeSeparators(
        os.path.join(resources.QML_FILES, qmlpath))
    path_qml = urlunparse(urlparse(path_qml)._replace(scheme='file'))
    return QUrl(path_qml)