public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/g-sorcery:dev commit in: g_sorcery/
@ 2014-09-29 19:38 Jauhien Piatlicki
  0 siblings, 0 replies; 7+ messages in thread
From: Jauhien Piatlicki @ 2014-09-29 19:38 UTC (permalink / raw
  To: gentoo-commits

commit:     2b33a61b659b35280616715fb9c522ef111520c7
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu May  8 01:03:47 2014 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Thu May  8 01:03:47 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=2b33a61b

g_sorcery/ebuild.py: fix typo

---
 g_sorcery/ebuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py
index c7fc463..31782f0 100644
--- a/g_sorcery/ebuild.py
+++ b/g_sorcery/ebuild.py
@@ -154,7 +154,7 @@ class DefaultEbuildGenerator(EbuildGenerator):
     Default ebuild generator.
 
     Takes a layout dictinary that describes ebuild structure and generates
-    an ebuild temlate basing on it.
+    an ebuild template basing on it.
 
     Layout has entries for vars and inherited eclasses. Each entry is a list.
     Entries are processed in the following order:


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/g-sorcery:dev commit in: g_sorcery/
@ 2014-11-24 14:25 Jauhien Piatlicki
  0 siblings, 0 replies; 7+ messages in thread
From: Jauhien Piatlicki @ 2014-11-24 14:25 UTC (permalink / raw
  To: gentoo-commits

commit:     3acb0ce6d38d02915f142f2ec69c9c24fb1ec99c
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 24 14:22:28 2014 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Mon Nov 24 14:22:28 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=3acb0ce6

[g_sorcery/g_sorcery.py] check backend initialization

---
 g_sorcery/g_sorcery.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py
index 76ecf82..b41adfb 100644
--- a/g_sorcery/g_sorcery.py
+++ b/g_sorcery/g_sorcery.py
@@ -4,9 +4,9 @@
 """
     g_sorcery.py
     ~~~~~~~~~~~~
-    
+
     the main module
-    
+
     :copyright: (c) 2013 by Jauhien Piatlicki
     :license: GPL-2, see LICENSE for more details.
 """
@@ -46,6 +46,10 @@ def main():
         return -1
     backend = get_backend(config['package'])
 
+    if not backend:
+        logger.error("backend initialization failed, exiting")
+        return -1
+
     config_file = None
     for path in '.', '~', '/etc/g-sorcery':
         config_file = os.path.join(path, "g-sorcery.cfg")
@@ -57,7 +61,7 @@ def main():
     if not config_file:
         logger.error('no global config file\n')
         return -1
-    
+
     global_config = configparser.ConfigParser()
     global_config.read(config_file)
 
@@ -74,7 +78,7 @@ def get_backend(package):
     except ImportError as error:
         logger.error("error importing backend: " + str(error))
         return None
-    
+
     return module
 
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/g-sorcery:dev commit in: g_sorcery/
  2015-04-22  7:35 [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/ Jauhien Piatlicki
@ 2015-04-20 21:36 ` Jauhien Piatlicki
  0 siblings, 0 replies; 7+ messages in thread
From: Jauhien Piatlicki @ 2015-04-20 21:36 UTC (permalink / raw
  To: gentoo-commits

commit:     eef3ee7168fbf38bb5ef56a47fee0c0873cd4540
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 17 07:27:02 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Fri Apr 17 07:27:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=eef3ee71

[g_sorcery] fix DB cleaning

do not write empty DB on cleaning,
so syncing with old (v. 0) DBs works

 g_sorcery/db_layout.py  | 1 +
 g_sorcery/package_db.py | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/db_layout.py b/g_sorcery/db_layout.py
index fe6f281..ea4298a 100644
--- a/g_sorcery/db_layout.py
+++ b/g_sorcery/db_layout.py
@@ -230,6 +230,7 @@ class DBLayout(object):
         """
         if os.path.exists(self.directory):
             shutil.rmtree(self.directory)
+        os.makedirs(self.directory)
 
     def read(self):
         """

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 5eeeb63..ec2d45f 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -216,7 +216,6 @@ class PackageDB(object):
         """
         self.db_layout.clean()
         self.reset_db()
-        self.write()
 
 
     def write(self):


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/g-sorcery:dev commit in: g_sorcery/
@ 2015-04-20 21:36 Jauhien Piatlicki
  0 siblings, 0 replies; 7+ messages in thread
From: Jauhien Piatlicki @ 2015-04-20 21:36 UTC (permalink / raw
  To: gentoo-commits

commit:     bbe16a229b42e96f847246d82e8f1bcff4d60a82
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 17 20:59:50 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Fri Apr 17 20:59:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=bbe16a22

[g_sorcery/db_layout,g_sorcery/package_db] better version/format checking, fix exceptions

 g_sorcery/db_layout.py  |  4 +++-
 g_sorcery/package_db.py | 19 +++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/g_sorcery/db_layout.py b/g_sorcery/db_layout.py
index da779bd..8eb81da 100644
--- a/g_sorcery/db_layout.py
+++ b/g_sorcery/db_layout.py
@@ -26,6 +26,8 @@ PACKAGES_FILE_NAME = 'packages'
 JSON_FILE_SUFFIX = 'json'
 BSON_FILE_SUFFIX = 'bson'
 
+SUPPORTED_DB_LAYOUTS=[0, 1]
+
 class CategoryJSON(FileJSON):
     """
     Category file in JSON format.
@@ -182,7 +184,7 @@ def get_layout(metadata):
             raise DBLayoutError("unsupported packages file format: " + category_format)
         return (category_cls, [file_name(CATEGORIES_FILE_NAME), file_name(METADATA_FILE_NAME)])
     else:
-        raise DBLayoutError("unsupported DB layout version: " + layout_version)
+        raise DBLayoutError("unsupported DB layout version: " + str(layout_version))
 
 
 class DBLayout(object):

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 5374ae5..4c67fdc 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -18,12 +18,13 @@ import portage
 
 from .compatibility import basestring, py2k, TemporaryDirectory
 
-from .db_layout import DBLayout, JSON_FILE_SUFFIX
-from .exceptions import DBError, DBStructureError, InvalidKeyError, SyncError
+from .db_layout import DBLayout, JSON_FILE_SUFFIX, SUPPORTED_DB_LAYOUTS, SUPPORTED_FILE_FORMATS
+from .exceptions import DBError, DBLayoutError, DBStructureError, InvalidKeyError, SyncError
 from .fileutils import FileJSON, load_remote_file, copy_all, wget
 from .g_collections import Package
 from .logger import Logger
 
+SUPPORTED_DB_STRUCTURES=[0, 1]
 
 class PackageDB(object):
     """
@@ -142,11 +143,17 @@ class PackageDB(object):
 
         if preferred_layout_version == 0 \
            and preferred_db_version != 0:
-            raise DBStructureError("Wrong DB version: " + preferred_db_version + \
+            raise DBStructureError("Wrong DB version: " + str(preferred_db_version) + \
                                    ", with DB layout version 0 it can be only 0")
 
-        if not preferred_db_version in [0, 1]:
-            raise DBStructureError("Unsupported DB version: " + preferred_db_version)
+        if not preferred_db_version in SUPPORTED_DB_STRUCTURES:
+            raise DBStructureError("Unsupported DB version: " + str(preferred_db_version))
+
+        if not preferred_layout_version in SUPPORTED_DB_LAYOUTS:
+            raise DBLayoutError("unsupported DB layout version: " + str(preferred_layout_version))
+
+        if not preferred_category_format in SUPPORTED_FILE_FORMATS:
+            raise DBLayoutError("unsupported packages file format: " + preferred_category_format)
 
         self.logger = Logger()
         self.directory = os.path.abspath(directory)
@@ -261,7 +268,7 @@ class PackageDB(object):
         elif db_version == 1:
             pass
         else:
-            raise DBStructureError("Unsupported DB version: " + db_version)
+            raise DBStructureError("Unsupported DB version: " + str(db_version))
 
 
     def add_category(self, category, description=None):


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/
@ 2015-04-22  7:35 Jauhien Piatlicki
  2015-04-20 21:36 ` [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
  0 siblings, 1 reply; 7+ messages in thread
From: Jauhien Piatlicki @ 2015-04-22  7:35 UTC (permalink / raw
  To: gentoo-commits

commit:     eef3ee7168fbf38bb5ef56a47fee0c0873cd4540
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 17 07:27:02 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Fri Apr 17 07:27:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=eef3ee71

[g_sorcery] fix DB cleaning

do not write empty DB on cleaning,
so syncing with old (v. 0) DBs works

 g_sorcery/db_layout.py  | 1 +
 g_sorcery/package_db.py | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/g_sorcery/db_layout.py b/g_sorcery/db_layout.py
index fe6f281..ea4298a 100644
--- a/g_sorcery/db_layout.py
+++ b/g_sorcery/db_layout.py
@@ -230,6 +230,7 @@ class DBLayout(object):
         """
         if os.path.exists(self.directory):
             shutil.rmtree(self.directory)
+        os.makedirs(self.directory)
 
     def read(self):
         """

diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 5eeeb63..ec2d45f 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -216,7 +216,6 @@ class PackageDB(object):
         """
         self.db_layout.clean()
         self.reset_db()
-        self.write()
 
 
     def write(self):


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/g-sorcery:dev commit in: g_sorcery/
@ 2015-08-18 10:41 Jauhien Piatlicki
  0 siblings, 0 replies; 7+ messages in thread
From: Jauhien Piatlicki @ 2015-08-18 10:41 UTC (permalink / raw
  To: gentoo-commits

commit:     e71fd837faf51fc0e9a123477bfc7558c24b37c0
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 16 22:43:08 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Sun Aug 16 22:43:08 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=e71fd837

[g_sorcery/fileutils] set wget timeout to 2 seconds

 g_sorcery/fileutils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index d783c8a..235eaec 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -149,9 +149,9 @@ def wget(uri, directory, output=""):
     """
     if output:
         ret = os.system('wget ' + uri +
-                    ' -O ' + os.path.join(directory, output))
+                        ' -O ' + os.path.join(directory, output) + ' -T 2')
     else:
-        ret = os.system('wget -P ' + directory + ' ' + uri)
+        ret = os.system('wget -P ' + directory + ' ' + uri + ' -T 2')
     return ret
 
 def get_pkgpath(root = None):


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/g-sorcery:dev commit in: g_sorcery/
  2015-08-18 18:59 [gentoo-commits] proj/g-sorcery:master " Jauhien Piatlicki
@ 2015-08-18 18:59 ` Jauhien Piatlicki
  0 siblings, 0 replies; 7+ messages in thread
From: Jauhien Piatlicki @ 2015-08-18 18:59 UTC (permalink / raw
  To: gentoo-commits

commit:     7716920fcfcf1595f6b575e1fe41c733c5ec7ab2
Author:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 18 18:07:55 2015 +0000
Commit:     Jauhien Piatlicki <jauhien <AT> gentoo <DOT> org>
CommitDate: Tue Aug 18 18:50:20 2015 +0000
URL:        https://gitweb.gentoo.org/proj/g-sorcery.git/commit/?id=7716920f

[g_sorcery/fileutils] make wget timeout optional

 g_sorcery/fileutils.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 235eaec..3440ec7 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -135,7 +135,7 @@ def copy_all(src, dst):
     """
     os.system("cp -rv " + src + "/* " + dst)
 
-def wget(uri, directory, output=""):
+def wget(uri, directory, output="", timeout = None):
     """
     Fetch a file.
 
@@ -143,15 +143,21 @@ def wget(uri, directory, output=""):
         uri: URI.
         directory: Directory where file should be saved.
         output: Name of output file.
+        timeout: Timeout for wget.
 
     Returns:
         Nonzero in case of a failure.
     """
+    if timeout is None:
+        timeout_str = ' '
+    else:
+        timeout_str = ' -T ' + str(timeout)
+
     if output:
         ret = os.system('wget ' + uri +
-                        ' -O ' + os.path.join(directory, output) + ' -T 2')
+                        ' -O ' + os.path.join(directory, output) + timeout_str)
     else:
-        ret = os.system('wget -P ' + directory + ' ' + uri + ' -T 2')
+        ret = os.system('wget -P ' + directory + ' ' + uri + timeout_str)
     return ret
 
 def get_pkgpath(root = None):
@@ -255,7 +261,7 @@ def _call_parser(f_name, parser, open_file = True, open_mode = 'r'):
     return {os.path.basename(f_name): data}
 
 
-def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
+def load_remote_file(uri, parser, open_file = True, open_mode = 'r', output = "", timeout = None):
     """
     Load files from an URI.
 
@@ -264,7 +270,8 @@ def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
         parser: Parser that will be applied to downloaded files.
         open_file: Whether parser accepts a file descriptor.
         open_mode: Open mode for a file.
-        output: What output name should downloaded file have
+        output: What output name should downloaded file have.
+        timeout: URI access timeout.
     (it will be a key identifying data loaded from this file)
 
     Returns:
@@ -272,7 +279,7 @@ def load_remote_file(uri, parser, open_file = True, open_mode='r', output=""):
     """
     download_dir = TemporaryDirectory()
     loaded_data = {}
-    if wget(uri, download_dir.name, output):
+    if wget(uri, download_dir.name, output, timeout=timeout):
         raise DownloadingError("wget failed: " + uri)
     for f_name in glob.glob(os.path.join(download_dir.name, "*")):
         if tarfile.is_tarfile(f_name):


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-08-18 18:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22  7:35 [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/ Jauhien Piatlicki
2015-04-20 21:36 ` [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
  -- strict thread matches above, loose matches on Subject: below --
2015-08-18 18:59 [gentoo-commits] proj/g-sorcery:master " Jauhien Piatlicki
2015-08-18 18:59 ` [gentoo-commits] proj/g-sorcery:dev " Jauhien Piatlicki
2015-08-18 10:41 Jauhien Piatlicki
2015-04-20 21:36 Jauhien Piatlicki
2014-11-24 14:25 Jauhien Piatlicki
2014-09-29 19:38 Jauhien Piatlicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox