コード例 #1
0
def parse_installed_plugins_worker(jar_queue, result_queue):
    """ Worker function of list_plugins.

    This function takes jars in the `jar_queue`, calculates the checksum,
    and extracts the main class, name and version and push this data to the
    `result_queue`.

    """
    while not jar_queue.empty():
        jar = jar_queue.get()

        checksum = common.checksum_file(jar)

        try:
            with ZipFile(jar, 'r') as zipped:
                if 'plugin.yml' not in zipped.namelist():
                    continue

                yml = yaml.load(zipped.read('plugin.yml').decode())
                plugin_name = yml['name']
                main = yml['main']
                version = str(yml['version'])

                result_queue.put((checksum, main, plugin_name, version, jar))
        except BadZipFile:
            print("    Could not read '{}'.".format(jar))

        jar_queue.task_done()
コード例 #2
0
    def identify(self):
        """ Identify what server a jar file is. """
        self.p_main('Calculating checksum of `{}`'.format(self.args.jar.name))

        checksum = utils.checksum_file(self.args.jar)
        self.args.jar.close()

        self.p_main('Finding build on SpaceGDN')

        build = backend.build_by_checksum(checksum)

        if build is None:
            self.p_main('Found no build on SpaceGDN with matching checksum')
            return

        server, channel, version, build_num = backend.get_roots(build)

        self.p_main('Checking for updates in channel')

        new_version, new_build = backend.find_newest(server, channel)
        appendix = ''
        if new_build > build_num:
            appendix = ' -- Out of date. Newest build: {} {}'.format(
                new_version, new_build)

        self.result(
            'Found build:',
            '{} {} {} {}'.format(server, channel, version, build_num) +
            appendix)
コード例 #3
0
ファイル: plugins.py プロジェクト: CubeEngine/mc-man
def parse_installed_plugins_worker(jar_queue, result_queue):
    """ Worker function of list_plugins.

    This function takes jars in the `jar_queue`, calculates the checksum,
    and extracts the main class, name and version and push this data to the
    `result_queue`.

    """
    while not jar_queue.empty():
        jar = jar_queue.get()

        checksum = common.checksum_file(jar)

        try:
            with ZipFile(jar, 'r') as zipped:
                if 'plugin.yml' not in zipped.namelist():
                    continue

                yml = yaml.load(zipped.read('plugin.yml').decode())
                plugin_name = yml['name']
                main = yml['main']
                version = str(yml['version'])

                result_queue.put((checksum, main, plugin_name, version, jar))
        except BadZipFile:
            print("    Could not read '{}'.".format(jar))

        jar_queue.task_done()
コード例 #4
0
ファイル: servers.py プロジェクト: CubeEngine/mc-man
    def identify(self):
        """ Identify what server a jar file is. """
        self.p_main("Calculating checksum of `{}`".format(self.args.jar.name))

        checksum = utils.checksum_file(self.args.jar)
        self.args.jar.close()

        self.p_main("Finding build on SpaceGDN")

        build = backend.build_by_checksum(checksum)

        if build is None:
            self.p_main("Found no build on SpaceGDN with matching checksum")
            return

        server, channel, version, build_num = backend.get_roots(build)

        self.p_main("Checking for updates in channel")

        new_version, new_build = backend.find_newest(server, channel)
        appendix = ""
        if new_build > build_num:
            appendix = " -- Out of date. Newest build: {} {}".format(new_version, new_build)

        self.result("Found build:", "{} {} {} {}".format(server, channel, version, build_num) + appendix)
コード例 #5
0
def list_servers():
    """ List servers in the current dir.

    Returned is a dictionary from jar file(relative path) to id

    """
    files = dict()

    for file in os.listdir():
        if not file.endswith('.jar'):
            continue
        checksum = common.checksum_file(file)
        build = build_by_checksum(checksum)
        if build is not None:
            files[file] = build['id']

    return files
コード例 #6
0
ファイル: servers.py プロジェクト: CubeEngine/mc-man
def list_servers():
    """ List servers in the current dir.

    Returned is a dictionary from jar file(relative path) to id

    """
    files = dict()

    for file in os.listdir():
        if not file.endswith('.jar'):
            continue
        checksum = common.checksum_file(file)
        build = build_by_checksum(checksum)
        if build is not None:
            files[file] = build['id']

    return files
コード例 #7
0
ファイル: test_common.py プロジェクト: CubeEngine/mc-man
 def test_path(self):
     """ Test with file path. """
     md5 = common.checksum_file(self.path)
     assert md5 == self.md5
コード例 #8
0
ファイル: test_common.py プロジェクト: CubeEngine/mc-man
 def test_file(self):
     """ Test with file object. """
     with open(self.path, 'rb') as file:
         md5 = common.checksum_file(file)
         assert md5 == self.md5
コード例 #9
0
 def test_path(self):
     """ Test with file path. """
     md5 = common.checksum_file(self.path)
     assert md5 == self.md5
コード例 #10
0
 def test_file(self):
     """ Test with file object. """
     with open(self.path, 'rb') as file:
         md5 = common.checksum_file(file)
         assert md5 == self.md5