コード例 #1
0
 def test_get_manifests_multiple_root(self):
     user_dbs, registry = self._setUpMultiDB()
     a_manifest_obj = {
         "name": "a",
         "version": "1.1",
         "_directory": os.path.join(user_dbs[1], "a"),
         "_removable": 1,
     }
     b_manifest_obj = {
         "name": "b",
         "version": "2.0",
         "_directory": os.path.join(user_dbs[0], "b"),
         "_removable": 1,
     }
     c_manifest_obj = {
         "name": "c",
         "version": "0.1",
         "_directory": os.path.join(user_dbs[1], "c"),
         "_removable": 1,
     }
     self.assertEqual([a_manifest_obj, c_manifest_obj, b_manifest_obj],
                      json_array_to_python(registry.get_manifests()))
     self.assertEqual([a_manifest_obj, c_manifest_obj, b_manifest_obj],
                      json.loads(registry.get_manifests_as_string()))
     registry.remove("b")
     self.assertEqual("@hidden", os.readlink(os.path.join(user_dbs[1],
                                                          "b")))
     self.assertEqual([a_manifest_obj, c_manifest_obj],
                      json_array_to_python(registry.get_manifests()))
     self.assertEqual([a_manifest_obj, c_manifest_obj],
                      json.loads(registry.get_manifests_as_string()))
コード例 #2
0
ファイル: list.py プロジェクト: ArtOS-Dev/UbPorts_Dump
def list_packages(options):
    db = Click.DB()
    db.read(db_dir=None)
    if options.root is not None:
        db.add(options.root)
    if options.all:
        return json_array_to_python(db.get_manifests(all_versions=True))
    else:
        registry = Click.User.for_user(db, name=options.user)
        return json_array_to_python(registry.get_manifests())
コード例 #3
0
 def test_manifests_all(self):
     with open(os.path.join(self.temp_dir, "a.conf"), "w") as a:
         print("[Click Database]", file=a)
         print("root = %s" % os.path.join(self.temp_dir, "a"), file=a)
     with open(os.path.join(self.temp_dir, "b.conf"), "w") as b:
         print("[Click Database]", file=b)
         print("root = %s" % os.path.join(self.temp_dir, "b"), file=b)
     db = Click.DB()
     db.read(db_dir=self.temp_dir)
     self.assertEqual([],
                      json_array_to_python(
                          db.get_manifests(all_versions=True)))
     self.assertEqual([],
                      json.loads(
                          db.get_manifests_as_string(all_versions=True)))
     a_pkg1_manifest_path = os.path.join(self.temp_dir, "a", "pkg1", "1.0",
                                         ".click", "info", "pkg1.manifest")
     a_pkg1_manifest_obj = {"name": "pkg1", "version": "1.0"}
     with mkfile(a_pkg1_manifest_path) as a_pkg1_manifest:
         json.dump(a_pkg1_manifest_obj, a_pkg1_manifest)
     os.symlink("1.0", os.path.join(self.temp_dir, "a", "pkg1", "current"))
     b_pkg1_manifest_path = os.path.join(self.temp_dir, "b", "pkg1", "1.1",
                                         ".click", "info", "pkg1.manifest")
     b_pkg1_manifest_obj = {"name": "pkg1", "version": "1.1"}
     with mkfile(b_pkg1_manifest_path) as b_pkg1_manifest:
         json.dump(b_pkg1_manifest_obj, b_pkg1_manifest)
     os.symlink("1.1", os.path.join(self.temp_dir, "b", "pkg1", "current"))
     b_pkg2_manifest_path = os.path.join(self.temp_dir, "b", "pkg2", "0.1",
                                         ".click", "info", "pkg2.manifest")
     b_pkg2_manifest_obj = {"name": "pkg2", "version": "0.1"}
     with mkfile(b_pkg2_manifest_path) as b_pkg2_manifest:
         json.dump(b_pkg2_manifest_obj, b_pkg2_manifest)
     os.symlink("0.1", os.path.join(self.temp_dir, "b", "pkg2", "current"))
     a_pkg1_manifest_obj["_directory"] = os.path.join(
         self.temp_dir, "a", "pkg1", "1.0")
     a_pkg1_manifest_obj["_removable"] = 0
     b_pkg1_manifest_obj["_directory"] = os.path.join(
         self.temp_dir, "b", "pkg1", "1.1")
     b_pkg1_manifest_obj["_removable"] = 1
     b_pkg2_manifest_obj["_directory"] = os.path.join(
         self.temp_dir, "b", "pkg2", "0.1")
     b_pkg2_manifest_obj["_removable"] = 1
     self.assertEqual(
         [b_pkg1_manifest_obj, b_pkg2_manifest_obj, a_pkg1_manifest_obj],
         json_array_to_python(db.get_manifests(all_versions=True)))
     self.assertEqual(
         [b_pkg1_manifest_obj, b_pkg2_manifest_obj, a_pkg1_manifest_obj],
         json.loads(db.get_manifests_as_string(all_versions=True)))
コード例 #4
0
 def test_get_manifests(self):
     registry = Click.User.for_user(self.db, "user")
     a_manifest_path = os.path.join(self.temp_dir, "a", "1.0", ".click",
                                    "info", "a.manifest")
     a_manifest_obj = {"name": "a", "version": "1.0"}
     with mkfile(a_manifest_path) as a_manifest:
         json.dump(a_manifest_obj, a_manifest)
     registry.set_version("a", "1.0")
     b_manifest_path = os.path.join(self.temp_dir, "b", "2.0", ".click",
                                    "info", "b.manifest")
     b_manifest_obj = {"name": "b", "version": "2.0"}
     with mkfile(b_manifest_path) as b_manifest:
         json.dump(b_manifest_obj, b_manifest)
     registry.set_version("b", "2.0")
     a_manifest_obj["_directory"] = os.path.join(registry.get_overlay_db(),
                                                 "a")
     a_manifest_obj["_removable"] = 1
     b_manifest_obj["_directory"] = os.path.join(registry.get_overlay_db(),
                                                 "b")
     b_manifest_obj["_removable"] = 1
     self.assertEqual([a_manifest_obj, b_manifest_obj],
                      json_array_to_python(registry.get_manifests()))
     self.assertEqual([a_manifest_obj, b_manifest_obj],
                      json.loads(registry.get_manifests_as_string()))