Пример #1
0
    def load(self):
        if os.path.isfile(
                os.path.join(
                    JustUpdateConstants.REPO_FOLDER,
                    "archive", "metadata-{}.ju".format(get_platform_name_short(
                    )))) == False and os.path.isfile(
                        os.path.join(
                            JustUpdateConstants.REPO_FOLDER, "deploy",
                            "metadata-{}.ju".format(
                                get_platform_name_short()))) == False:
            logging.debug("No metadata for platform {} found.".format(
                get_platform_name_short()))
            return {}

        # ok the metadata file most exist. Try to load it.
        # first see if there's one in deploy, if not, go for the one in archive.
        data = b""
        try:
            data = data_manager.open_file(
                os.path.join(
                    JustUpdateConstants.REPO_FOLDER, "deploy",
                    "metadata-{}.ju".format(get_platform_name_short())), "rb")
        except FileNotFoundError:
            data = data_manager.open_file(
                os.path.join(
                    JustUpdateConstants.REPO_FOLDER, "archive",
                    "metadata-{}.ju".format(get_platform_name_short())), "rb")
        data = data_manager.decompress(data)
        data = json.loads(data)
        return data
Пример #2
0
def test_platform_names():
	platform_name = platform.system()
	
	if platform_name == "Windows":
		assert get_platform_name_short() == "win"
	if platform_name == "Darwin":
		assert get_platform_name_short() == "mac"
Пример #3
0
	def clean(self):
		try:
			shutil.rmtree(os.path.join(JustUpdateConstants.REPO_FOLDER, "work"))
		except FileNotFoundError:
			pass # It's ok if the folder doesn't exist.
		cmd = getattr(self, "_clean_{}".format(get_platform_name_short()))
		return cmd()
Пример #4
0
def _cmd_make_spec(args, extra=None):
    cmd = ["pyi-makespec", "--name",
           get_platform_name_short()] + extra + [args.scriptname]
    executor = CommandExecutor()
    result, stdout = executor.execute(cmd, CommandType.RAW)
    if result > 0:  # error
        print(stdout)
        logging.error("Please correct the errors above and try again.")
    else:
        logging.info("Spec file written.")
    return True
Пример #5
0
 def _load_metadata(self, bypass_metadata_cache_cache):
     md = ""
     try:
         md = self._download_metadata(
             "metadata-{}.ju".format(get_platform_name_short()),
             bypass_metadata_cache_cache)
     except requests.ConnectTimeout:
         return None
     except:
         raise
     md = data_manager.decompress(md)
     md = json.loads(md)
     metadata = MetaData()
     metadata.apply_metadata(md)
     return metadata
Пример #6
0
 def save(self):
     if os.path.isdir(
             os.path.join(JustUpdateConstants.REPO_FOLDER,
                          "deploy")) == False:
         os.makedirs(os.path.join(JustUpdateConstants.REPO_FOLDER,
                                  "deploy"))
     data = json.dumps(self._metadata)
     data = data_manager.compress(data)
     f = open(
         os.path.join(JustUpdateConstants.REPO_FOLDER, "deploy",
                      "metadata-{}.ju".format(get_platform_name_short())),
         "wb")
     f.write(data)
     f.close()
     return self
Пример #7
0
def prepare_template(version):
    config = Config()
    config.load(os.path.join(JustUpdateConstants.REPO_FOLDER, "config.ju"))
    cmd = getattr(sys.modules[__name__],
                  "_prepare_template_{}".format(get_platform_name_short()))
    return cmd(version, config)
Пример #8
0
	def post_build(self):
		cmd = getattr(self, "_post_build_{}".format(get_platform_name_short()))
		return cmd()
Пример #9
0
 def get_metadata_for_version(self, version):
     if version not in self._metadata:
         raise UnknownMetaDataError(
             "Metadata for version {} on platform {} does not exist.".
             format(version, get_platform_name_short()))
     return self._metadata[version]
Пример #10
0
 def finalize(self):
     cmd = getattr(self, "_finalize_{}".format(get_platform_name_short()))
     return cmd()
Пример #11
0
 def create_metadata(self):
     cmd = getattr(self,
                   "_create_metadata_{}".format(get_platform_name_short()))
     return cmd()
Пример #12
0
 def produce_executable(self):
     cmd = getattr(
         self, "_produce_executable_{}".format(get_platform_name_short()))
     return cmd()
Пример #13
0
 def insure_build_availability(self):
     cmd = getattr(
         self,
         "_insure_build_availability_{}".format(get_platform_name_short()))
     return cmd()