[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pulp-list] Fwd: [katello-devel] Python import advice



Can anyone help?

-J

-------- Original Message --------
Subject: [katello-devel] Python import advice
Date: Thu, 28 Jul 2011 17:03:19 +0200
From: Lukas Zapletal <lzap redhat com>
To: katello-devel redhat com

Hello,

could anyone help me with a python import problem?

I am trying to import a class and I dont know - its refusing to import
it for me. I think there must be something wrong with my setup.

Please try to apply this small patch (current master) and try:

katello user list

(or anything - import failure occurs for me)

Thanks

Traceback (most recent call last):
   File "/home/lzap/Work/CloudForms/katello/cli/bin/katello", line 19,
in <module>
     from katello.client.cli.admin import AdminCLI
   File
"/home/lzap/Work/CloudForms/katello/cli/src/katello/client/cli/admin.py", line

16, in <module>
     from katello.client.cli.base import KatelloCLI
   File
"/home/lzap/Work/CloudForms/katello/cli/src/katello/client/cli/base.py",
line 23, in <module>
     from katello.client.core.utils import parse_tokens
   File
"/home/lzap/Work/CloudForms/katello/cli/src/katello/client/core/utils.py",
line 23, in <module>
     from katello.client.cli.base import KatelloError
ImportError: cannot import name KatelloError

-- 
Later,

  Lukas Zapletal | E32E400A
  RHN Satellite Engineering
  Red Hat Czech s.r.o. Brno

diff --git a/cli/src/katello/client/core/utils.py b/cli/src/katello/client/core/utils.py
index 3df8773..c72fb3a 100644
--- a/cli/src/katello/client/core/utils.py
+++ b/cli/src/katello/client/core/utils.py
@@ -20,6 +20,7 @@ import time
 import threading
 import time
 from katello.client.api.task_status import TaskStatusAPI
+from katello.client.cli.base import KatelloError
 
 # output formatting -----------------------------------------------------------
 
@@ -297,18 +298,21 @@ def parse_tokens(tokenstring):
     @return List of tokens
     """
     tokens = []
-    pattern = '--?\w+|=?"[^"]*"|=?\'[^\']*\'|=?[^\s]+'
+    try:
+        pattern = '--?\w+|=?"[^"]*"|=?\'[^\']*\'|=?[^\s]+'
 
-    print tokenstring
-    for tok in (re.findall(pattern, tokenstring)):
+        print tokenstring
+        for tok in (re.findall(pattern, tokenstring)):
 
-        if tok[0] == '=':
-            tok = tok[1:]
-        if tok[0] == '"' or tok[0] == "'":
-            tok = tok[1:-1]
+            if tok[0] == '=':
+                tok = tok[1:]
+            if tok[0] == '"' or tok[0] == "'":
+                tok = tok[1:-1]
 
-        tokens.append(tok)
-    return tokens
+            tokens.append(tok)
+        return tokens
+    except Exception, e:
+        raise KatelloError("Unable to parse options", e)
 
 
 def get_abs_path(path):

_______________________________________________
katello-devel mailing list
katello-devel redhat com
https://www.redhat.com/mailman/listinfo/katello-devel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]