2013-12-09 49 views
0

我正在使用Redhawk 1.9。我從1.8.4 IDE創建了一個Redhawk設備。將Redhawk設備從1.8.4轉換爲1.9時的轉換錯誤

我將默認的1.8.4設備導入到1.9 IDE中。我能夠在1.9 IDE中運行和構建1.8.4設備。當我嘗試重新生成1.8.4設備的代碼時,IDE問我是否要升級到1.9。彈出窗口中顯示「ConversionTestDevice使用了不推薦的代碼生成器,你想升級這個項目嗎?」。我決定做一次升級。然後我收到以下錯誤信息: 文件「在/ usr /本地/紅鷹:

在/ usr /本地/紅鷹/核心/斌/ update_project,錯誤代碼1

回溯(最近通話最後一個)返回/ core/bin/update_project「,第222行,在?如果check_bulkio_input(compCpp)爲 : 對於strip_comments(打開(文件名,'r'))行中的文件「/ usr/local/redhawk/core/bin/update_project」,第105行,在check_bulkio_input中 : 文件「/ usr/local/redhawk/core/bin/update_project「,第86行,在strip_comments中 return next (item) NameError:未定義全局名稱'next'

我將不勝感激關於如何將1.8.4設備轉換爲1.9設備的建議。

+0

我發現update_project python腳本與Python版本2.4.3不兼容。看來這個版本的python不能識別迭代器上的下一個命令。在嘗試更高版本的python時,升級腳本按預期工作。 –

+0

我使用的是Python 2.4.3版本附帶的CentOS 5.3。 –

回答

0

根據您的錯誤消息「NameError:global name'next'未定義」以及1.9.0版本的update_project python腳本的內容,我假設您正在運行的python版本低於2.6。下一個函數是Python 2.6中引入的python內建函數(http://docs.python.org/2/library/functions.html#next)。這是升級腳本中的一個已知錯誤,因爲它應該與Python 2.4以及Python 2.6兼容(分別爲CentOS 5和6中的默認python安裝)。爲了解決這個問題,你可以修改位於$ OSSIEHOME /斌/ update_project的update_project腳本並定義以下功能:

if not hasattr(__builtins__, 'next'): 
    # Python 2.4 does not have a free-standing next() function 
    def next(iterator, default): 
     """ 
     Backwards compatibility next() equivalent for Python 2.4. 
     """ 
     try: 
      return iterator.next() 
     except StopIteration: 
      return default 

然後您應該刪除以前定義的「safe_next」功能。

最後,你需要給新執行下一個功能,並添加空字符串「」

爲了清楚起見,update_project的這些改變的差異的第二個參數調用替換兩次調用「safe_next」如下:

@@ -46,16 +46,16 @@ Options: 

_bulkio_re = re.compile('BULKIO_data[A-Za-z]+_In_i') 

-def safe_next(item): 
- """ 
- Returns the next value of the iterator, or an empty string if the end of 
- iteration has been reached. Allows string processing to gracefully handle 
- the end of a line without explicit catch statements. 
- """ 
- try: 
-  return next(item) 
- except StopIteration: 
-  return '' 
+if not hasattr(__builtins__, 'next'): 
+ # Python 2.4 does not have a free-standing next() function 
+ def next(iterator, default): 
+  """ 
+  Backwards compatibility next() equivalent for Python 2.4. 
+  """ 
+  try: 
+   return iterator.next() 
+  except StopIteration: 
+   return default 

def strip_comments(source): 
    """ 
@@ -75,7 +75,7 @@ def strip_comments(source): 
       # Look for end comment token; if the end of the line is reached 
       # ch will be an empty string 
       while ch == '*': 
-     ch = safe_next(chars) 
+     ch = next(chars, '') 
        if ch == '/': 
         inComment = False 
         break 
@@ -83,7 +83,7 @@ def strip_comments(source): 
      if ch == '/': 
       # Read the next character to see if it matches a comment token 
       # (if it does not, both characters will be added to the output) 
-    ch += safe_next(chars) 
+    ch += next(chars, '') 
       if ch == '/*': 
        # Comment, start discarding 
        inComment = True