Exemple #1
0
 def test02_FolderExporterPostProcess(self):
     """Test folder exporter post processing"""
     e = FolderExporter()
     result = WriterResult()
     result.index_file = '/tmp/file.htm'
     e.postProcess(result)
     self.assertEqual(e.destinationUrl(), '/tmp/file.htm')
Exemple #2
0
    def test08_FtpExporterTempFolder(self):
        """Test FTP exporter generation of temp folder"""
        e = FtpExporter()
        e.host = None
        self.assertTrue(e.exportDirectory())
        prev_folder = e.exportDirectory()

        result = WriterResult()
        result.index_file = ''
        e.postProcess(result)
        # a new export folder should be generated to avoid outdated files
        self.assertNotEqual(e.exportDirectory(), prev_folder)
Exemple #3
0
    def test09_FtpUpload(self):
        e = FtpExporter()
        e.host = 'localhost'
        e.port = TEST_PORT
        e.username = '******'
        e.password = '******'

        # copy some files to export directory
        export_folder = e.exportDirectory()
        try:
            os.makedirs(export_folder)
        except:
            self.assertTrue(False, 'could not create export directory')
        out_file = os.path.join(export_folder, 'index.html')
        with open(out_file, 'w') as i:
            i.write('test')

        result = WriterResult()
        result.index_file = out_file
        result.folder = export_folder
        e.postProcess(result)

        expected_index_file = os.path.join(
            FTP_USER_FOLDER, 'public_html', 'index.html')
        self.assertTrue(os.path.exists(expected_index_file))
        content = open(expected_index_file, 'r').readlines()
        self.assertEqual(content, ['test'])

        # try overwriting existing file
        with open(out_file, 'w') as i:
            i.write('test2')
        result = WriterResult()
        result.index_file = out_file
        result.folder = export_folder
        e.postProcess(result)
        self.assertTrue(expected_index_file)
        content = open(expected_index_file, 'r').readlines()
        self.assertEqual(content, ['test2'])
Exemple #4
0
    def write(self, iface, dest_folder, feedback=None):
        if not feedback:
            feedback = Feedback()

        feedback.showFeedback('Creating Leaflet map...')
        self.preview_file = self.writeLeaflet(iface, feedback,
                                              layer_list=self.layers,
                                              popup=self.popup,
                                              visible=self.visible,
                                              json=self.json,
                                              cluster=self.cluster,
                                              params=self.params,
                                              folder=dest_folder)
        result = WriterResult()
        result.index_file = self.preview_file
        result.folder = os.path.dirname(self.preview_file)
        for dirpath, dirnames, filenames in os.walk(result.folder):
            result.files.extend([os.path.join(dirpath, f) for f in filenames])
        return result
Exemple #5
0
    def write(self, iface, dest_folder, feedback=None):
        if not feedback:
            feedback = Feedback()

        feedback.showFeedback('Creating OpenLayers map...')

        self.preview_file = self.writeOL(iface,
                                         feedback,
                                         layers=self.layers,
                                         groups=self.groups,
                                         popup=self.popup,
                                         visible=self.visible,
                                         json=self.json,
                                         clustered=self.cluster,
                                         getFeatureInfo=self.getFeatureInfo,
                                         settings=self.params,
                                         folder=dest_folder)
        result = WriterResult()
        result.index_file = self.preview_file
        result.folder = os.path.dirname(self.preview_file)
        for dirpath, dirnames, filenames in os.walk(result.folder):
            result.files.extend([os.path.join(dirpath, f) for f in filenames])
        return result