Exemple #1
0
    def prepare_res_folder_for_executable(self):
        if not os.path.exists(self.src_res_path):
            os.makedirs(self.src_res_path)

        utils.copytree(self.res_common_path, self.src_res_path, force_copy=True)
        utils.copytree(self.res_platform_path, self.src_res_path, force_copy=True)
        BitbloqLibsUpdater().restore_current_version_if_necessary()
Exemple #2
0
def restore_test_resources(relative_path=""):
    settings_path = os.path.join(PathsManager.TEST_SETTINGS_PATH, relative_path)
    res_path = os.path.join(PathsManager.TEST_RES_PATH, relative_path)
    if os.path.exists(PathsManager.TEST_SETTINGS_PATH):
        utils.remove_folder(PathsManager.TEST_SETTINGS_PATH)
    os.makedirs(settings_path)
    if os.path.isdir(res_path):
        utils.copytree(res_path, settings_path, ignore=".pioenvs", force_copy=True)
Exemple #3
0
    def _move_libs_to_destination(self, downloaded_path):
        directories_in_folder = utils.list_directories_in_path(downloaded_path)
        if len(directories_in_folder) != 1:
            raise BitbloqLibsUpdaterError("Not only one bitbloqLibs folder in unzipped file")
        downloaded_path = downloaded_path + os.sep + directories_in_folder[0]

        if not os.path.exists(self.destination_path):
            os.makedirs(self.destination_path)
        utils.copytree(downloaded_path, self.destination_path, force_copy=True)
Exemple #4
0
    def _move_libs_to_destination(self, downloaded_path):
        directories_in_folder = utils.list_directories_in_path(downloaded_path)
        if len(directories_in_folder) != 1:
            raise BitbloqLibsUpdaterError(
                "Not only one bitbloqLibs folder in unzipped file")
        downloaded_path = downloaded_path + os.sep + directories_in_folder[0]

        if not os.path.exists(self.destination_path):
            os.makedirs(self.destination_path)
        utils.copytree(downloaded_path, self.destination_path, force_copy=True)
Exemple #5
0
    def _construct_link_executable(self):
        self._clear_build_files()
        os.chdir(self.src_path)
        log.debug("Creating Web2boardLink Executable")
        os.system("pyinstaller -w --onefile \"{}\"".format(self.web2board_path + os.sep + "web2boardLink-mac.spec"))
        utils.copytree(os.path.join(self.pyinstaller_dist_folder, "web2boardLink.app"), self.installerCreationAppPath)

        w2b_origin = os.path.join(self.installer_creation_dist_path, 'web2board')
        w2b_dst = os.path.join(self.app_resources_path, os.pardir, 'web2board')
        shutil.move(w2b_origin, w2b_dst)
        utils.copytree(self.res_common_path, self.app_resources_path)
Exemple #6
0
    def test_copytree_doNotOverwriteExistingFiles(self):
        os.mkdir(self.copy_tree_new)
        txt_file_path = self.copy_tree_new + os.path.sep + "01.txt"
        with open(txt_file_path, "w") as f:
            f.write("01")

        utils.copytree(self.copy_tree_old, self.copy_tree_new)
        with open(txt_file_path, "r") as f:
            file_data = f.read()

        self.__assertCopyTreeNewHasAllFiles()
        self.assertEqual(file_data, "01")
Exemple #7
0
    def test_copytree_doNotOverwriteExistingFiles(self):
        os.mkdir(self.copy_tree_new)
        txt_file_path = self.copy_tree_new + os.path.sep + "01.txt"
        with open(txt_file_path, "w") as f:
            f.write("01")

        utils.copytree(self.copy_tree_old, self.copy_tree_new)
        with open(txt_file_path, "r") as f:
            file_data = f.read()

        self.__assertCopyTreeNewHasAllFiles()
        self.assertEqual(file_data, "01")
Exemple #8
0
def restore_test_resources(relative_path=""):
    settings_path = os.path.join(PathsManager.TEST_SETTINGS_PATH,
                                 relative_path)
    res_path = os.path.join(PathsManager.TEST_RES_PATH, relative_path)
    if os.path.exists(PathsManager.TEST_SETTINGS_PATH):
        utils.remove_folder(PathsManager.TEST_SETTINGS_PATH)
    os.makedirs(settings_path)
    if os.path.isdir(res_path):
        utils.copytree(res_path,
                       settings_path,
                       ignore=".pioenvs",
                       force_copy=True)
Exemple #9
0
    def update(self, version, destination):
        version_path = pm.get_dst_path_for_update(version)
        confirm_path = version_path + ".confirm"
        if not os.path.isdir(version_path) or not os.path.isfile(confirm_path):
            raise UpdaterError("Unable to update, not all necessary files downloaded")

        self.log.info("updating in process")
        utils.copytree(version_path, destination)

        if os.path.exists(destination):
            self.log.info("removing original files")
            utils.rmtree(destination)
            self.log.info("removed original files")
        else:
            os.makedirs(destination)
        utils.copytree(version_path, destination)
Exemple #10
0
    def _construct_link_executable(self):
        self._clear_build_files()
        os.chdir(self.src_path)
        log.debug("Creating Web2boardLink Executable")
        os.system(
            "pyinstaller -w --onefile \"{}\"".format(self.web2board_path +
                                                     os.sep +
                                                     "web2boardLink-mac.spec"))
        utils.copytree(
            os.path.join(self.pyinstaller_dist_folder, "web2boardLink.app"),
            self.installerCreationAppPath)

        w2b_origin = os.path.join(self.installer_creation_dist_path,
                                  'web2board')
        w2b_dst = os.path.join(self.app_resources_path, os.pardir, 'web2board')
        shutil.move(w2b_origin, w2b_dst)
        utils.copytree(self.res_common_path, self.app_resources_path)
Exemple #11
0
    def update(self, version, destination):
        version_path = pm.get_dst_path_for_update(version)
        confirm_path = version_path + ".confirm"
        if not os.path.isdir(version_path) or not os.path.isfile(confirm_path):
            raise UpdaterError(
                "Unable to update, not all necessary files downloaded")

        self.log.info("updating in process")
        utils.copytree(version_path, destination)

        if os.path.exists(destination):
            self.log.info("removing original files")
            utils.rmtree(destination)
            self.log.info("removed original files")
        else:
            os.makedirs(destination)
        utils.copytree(version_path, destination)
Exemple #12
0
import os
import platform
from os.path import join
import shutil


platform_to_folder = dict(Linux="linux", Windows="windows", Darwin="darwin")

modulePath = os.path.abspath(os.path.dirname(inspect.getframeinfo(inspect.currentframe()).filename))
os.chdir(modulePath)
resPath = os.path.abspath(os.path.normpath(join(modulePath, os.pardir, os.pardir, "res")))
srcPath = os.path.abspath(os.path.normpath(join(modulePath, os.pardir)))

resPlatformPath = join(resPath, platform_to_folder[platform.system()])
resCommonPath = join(resPath, "common")

srcResPath = join(srcPath, "res")

sys.path += [srcPath]


if "removeFolder" in sys.argv:
    if os.path.exists(srcResPath):
        shutil.rmtree(srcResPath)
if not os.path.exists(srcResPath):
    os.makedirs(srcResPath)

from libs import utils

utils.copytree(resCommonPath, srcResPath, force_copy=True)
utils.copytree(resPlatformPath, srcResPath, force_copy=True)
Exemple #13
0
    def test_copytree_createsNewFolderIfNotExists(self):
        utils.copytree(self.copy_tree_old, self.copy_tree_new)

        self.__assertCopyTreeNewHasAllFiles()
Exemple #14
0
    def test_copytree_worksEvenWithExistingFolder(self):
        os.mkdir(self.copy_tree_new)

        utils.copytree(self.copy_tree_old, self.copy_tree_new)

        self.__assertCopyTreeNewHasAllFiles()
Exemple #15
0
 def _construct_web2board_executable(self):
     log.debug("Creating Web2board Executable")
     os.system("pyinstaller \"{}\"".format(self.web2board_spec_path))
     src = join(self.pyinstaller_dist_folder, "web2board")
     dst = join(self.installer_creation_dist_path, "web2board")
     utils.copytree(src, dst)
Exemple #16
0
 def _construct_link_executable(self):
     os.chdir(self.src_path)
     log.debug("Creating Web2boardLink Executable")
     os.system("pyinstaller -w \"{}\"".format("web2boardLink.py"))
     utils.copytree(join(self.pyinstaller_dist_folder, "web2boardLink"), self.installer_creation_dist_path)
Exemple #17
0
    def test_copytree_worksEvenWithExistingFolder(self):
        os.mkdir(self.copy_tree_new)

        utils.copytree(self.copy_tree_old, self.copy_tree_new)

        self.__assertCopyTreeNewHasAllFiles()
Exemple #18
0
    def test_copytree_createsNewFolderIfNotExists(self):
        utils.copytree(self.copy_tree_old, self.copy_tree_new)

        self.__assertCopyTreeNewHasAllFiles()