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)) f = open(expected_index_file, 'r') content = f.readlines() f.close() 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) f = open(expected_index_file, 'r') content = f.readlines() f.close() self.assertEqual(content, ['test2'])
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 Exception: 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)) f = open(expected_index_file, 'r') content = f.readlines() f.close() 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) f = open(expected_index_file, 'r') content = f.readlines() f.close() self.assertEqual(content, ['test2'])
def write(self, iface, dest_folder, feedback=None): if not feedback: feedback = Feedback() feedback.showFeedback('Creating Mapbox map...') self.preview_file = self.writeMapbox( iface, feedback, layer_list=self.layers, popup=self.popup, visible=self.visible, json=self.json, cluster=self.cluster, getFeatureInfo=self.getFeatureInfo, 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
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