def test_extract(self): #empty output directory utils.init_path(self.output_dir) utils.extract(self.archive_file, self.output_dir) files = os.listdir(self.output_dir) with tarfile.open(self.archive_file) as f: for file in files: assert file in f.getnames()
def test_init_path_clear_non_empty_dir(self): if not os.path.exists(self.output_dir): os.makedirs(self.output_dir) data = 'hello world! test data' with open(self.test_file, "w") as outfile: json.dump(data, outfile) assert os.path.exists(self.test_file) is True utils.init_path(self.output_dir) assert os.path.exists(self.test_file) is False
def run(self): bok = True arstatus = [] utils.init_path(self.get_path_native()) utils.info("BEGIN DEPENDENCIES") try: if utils.is_windows(): self._dependency("lib_gcc", "8.1.0", arstatus) self._dependency("lib_stdcpp", "8.1.0", arstatus) self._dependency("lib_z", "1.2.11", arstatus) self._dependency("lib_turbojpeg", "2.0.3", arstatus) self._dependency("lib_opus", "21.3.1", arstatus) self._dependency("lib_rtaudio", "5.1.0", arstatus) utils.info("END DEPENDENCIES") except: bok = False utils.info("ERROR DEPENDENCIES") if bok: utils.info("BEGIN COMPILE ALL") try: self._compile(compile_lib_core, arstatus) self._compile(compile_lib_gdi, arstatus) self._compile(compile_lib_osutil, arstatus) if utils.is_windows(): self._compile(compile_os_win_launcher, arstatus) self._compile(compile_os_win_service, arstatus) self._compile(compile_os_win_updater, arstatus) self._compile(compile_lib_screencapture, arstatus) self._compile(compile_lib_soundcapture, arstatus) utils.info("END COMPILE ALL") except: bok = False utils.info("ERROR COMPILE ALL") utils.info("") utils.info("") utils.info("STATUS:") for n in arstatus: utils.info(n) utils.info("") if bok: utils.info("ALL COMPILED CORRECTLY.") else: utils.info("ERRORS OCCURRED.")
def _dependency(self, snm, sver, ars): spth = self.get_path_tmp() + os.sep + snm smsg = snm + " " + sver utils.info("BEGIN " + snm) try: conf = utils.read_json_file(spth + os.sep + snm + ".json") bupd = True if conf is not None: if "version" in conf: if conf["version"] == sver: bupd = False else: utils.info("incorrect version.") else: utils.info("version not found.") else: utils.info("version not found.") if bupd: sfx = detectinfo.get_native_suffix() if sfx is None or "generic" in sfx: utils.info("os not detected.") raise Exception("You have to compile it manually.") if self._b32bit: sfx = sfx.replace("64", "32") utils.init_path(spth) utils.info("download headers and library ...") nurl = utils.get_node_url() if snm is not "lib_gcc" and snm is not "lib_stdcpp": appnm = "headers_" + snm + ".zip" utils.download_file(nurl + "getAgentFile.dw?name=" + appnm, spth + os.sep + appnm) utils.unzip_file(spth + os.sep + appnm, spth + os.sep) utils.remove_file(spth + os.sep + appnm) appnm = snm + "_" + sfx + ".zip" utils.download_file(nurl + "getAgentFile.dw?name=" + appnm, spth + os.sep + appnm) utils.unzip_file(spth + os.sep + appnm, spth + os.sep, "native/") utils.remove_file(spth + os.sep + appnm) #FIX Version conf = utils.read_json_file(spth + os.sep + snm + ".json") if conf is not None: if "version" not in conf: conf["version"] = sver utils.write_json_file(conf, spth + os.sep + snm + ".json") #COPY LIB TO NATIVE for f in os.listdir(spth): if f.endswith('.dll') or f.endswith('.so') or f.endswith( '.dylib'): shutil.copy2(spth + os.sep + f, self.get_path_native() + os.sep + f) #POST FIX self._dependency_post_fix(snm, sver) smsg += " - OK!" ars.append(smsg) utils.info("END " + snm) except Exception as e: smsg += " - ERROR: " + utils.exception_to_string(e) ars.append(smsg) raise e
def test_init_path(self): assert os.path.exists(self.output_dir) is False utils.init_path(self.output_dir) assert os.path.exists(self.output_dir) is True