Kaydet (Commit) 20b68f6b authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Rebuild-DB için api çağırılmayacak

Fonksiyon api içinden filesdb içine taşındı.
üst 2b097d7e
......@@ -272,9 +272,6 @@ def dirName(filePath):
"""return the directory name of pathname path"""
return os.path.dirname(filePath)
##FIXME:there are an important error in here please##
## fix here tomorrow (don't forget) ##
def system(command):
# command an list but should be an str
sys.stdout.write(command + "\n")
......
......@@ -148,30 +148,10 @@ def set_options(options):
ctx.config.set_options(options)
# FIXME: rebuild_db is only here for filesdb and it really is ugly. we should not need any rebuild.
@inary.util.locked
def rebuild_db():
# save parameters and shutdown inary
options = ctx.config.options
ui = ctx.ui
scom = ctx.scom
from inary import _cleanup
_cleanup()
ctx.filesdb.close()
ctx.filesdb.destroy()
ctx.filesdb = inary.db.filesdb.FilesDB()
ctx.filesdb.update()
# reinitialize everything
ctx.ui = ui
ctx.config.set_options(options)
ctx.scom = scom
# The following are INARY operations which constitute the INARY API
# Within functions
from inary.analyzer.conflict import calculate_conflicts
from inary.db.filesdb import rebuild_db
from inary.data.index import index
from inary.data.pgraph import package_graph
from inary.fetcher import fetch
......
......@@ -62,7 +62,7 @@ class CLI(inary.ui.UI):
def output(self, msg, err=False, verbose=False):
if (verbose and self.show_verbose) or (not verbose):
if isinstance(type(msg), type(bytes)):
if isinstance(msg, bytes):
msg = msg.decode('utf-8')
if err:
sys.stderr.write(str(msg))
......
......@@ -72,8 +72,11 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
'checking the distribution of the repository.\n'
'Do you want to continue?').format(name)):
return
if indexuri.endswith(".xml.xz") or indexuri.endswith(".xml"):
repository.add_repo(name, indexuri, ctx.get_option('at'))
else:
raise Exception(_("Extension of URI must be \".xml.xz\" or \".xml\" "))
repository.add_repo(name, indexuri, ctx.get_option('at'))
else:
self.help()
......
......@@ -66,7 +66,6 @@ Lists the packages that will be upgraded.
component = ctx.get_option('component')
if component:
# FIXME: INARY api is insufficient to do this
component_pkgs = self.componentdb.get_union_packages(component, walk=True)
upgradable_pkgs = list(set(upgradable_pkgs) & set(component_pkgs))
......
......@@ -21,7 +21,7 @@ _ = __trans.gettext
import inary.cli.command as command
import inary.context as ctx
import inary.api
import inary.db.filesdb
class RebuildDb(command.Command, metaclass=command.autocommand):
......@@ -51,4 +51,4 @@ dirs under /var/lib/inary
def run(self):
self.init(database=True)
if ctx.ui.confirm(str(_('Rebuild INARY databases?'))):
inary.api.rebuild_db()
inary.db.filesdb.rebuild_db()
......@@ -18,6 +18,7 @@ import shelve
import inary.context as ctx
import inary.db
import inary.db.lazydb as lazydb
import inary.util
import gettext
__trans = gettext.translation('inary', fallback=True)
......@@ -119,3 +120,22 @@ class FilesDB(lazydb.LazyDB):
files_db = os.path.join(ctx.config.info_dir(), ctx.const.files_db)
os.remove(files_db)
self.__check_filesdb()
@inary.util.locked
def rebuild_db():
# save parameters and shutdown inary
options = ctx.config.options
ui = ctx.ui
scom = ctx.scom
from inary import _cleanup
_cleanup()
ctx.filesdb.close()
ctx.filesdb.destroy()
ctx.filesdb = inary.db.filesdb.FilesDB()
ctx.filesdb.update()
# reinitialize everything
ctx.ui = ui
ctx.config.set_options(options)
ctx.scom = scom
......@@ -54,7 +54,7 @@ class Error(inary.errors.Error):
class InvalidSignature(inary.errors.Error):
def __init__(self, url):
inary.errors.Exception.__init__(self, _(" invalid for {}").format(url))
inary.errors.Exception.__init__(self, _("GPG Signature is invalid for {}").format(url))
self.url = url
......
......@@ -38,8 +38,6 @@ def install_pkg_names(A, reinstall=False, extra=False):
installdb = inary.db.installdb.InstallDB()
packagedb = inary.db.packagedb.PackageDB()
A = [str(x) for x in A] # FIXME: why do we still get unicode input here? :/
# A was a list, remove duplicates
A_0 = A = set(A)
......
......@@ -79,6 +79,6 @@ def search_file(term):
>>> [("kvm", (["lib/modules/2.6.18.8-86/extra/kvm-amd.ko","lib/modules/2.6.18.8-86/extra/kvm-intel.ko"])),]
"""
if term.startswith("/"): # FIXME: why? why?
if term.startswith("/"):
term = term[1:]
return ctx.filesdb.search_file(term)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment