2017-08-08 32 views
0

我遇到一個奇怪的問題。我有一個Debian 2015-11-03的BBB。我的python 2.7應用程序在啓動時自動運行。我在腳本中做一些文件管理。在這種情況下,腳本的那部分不起作用。沒有錯誤信息可見。根本不值一提。當我在LX終端(sudo python aceme.py,與自動模式相同的命令行,相同的目錄)手動啓動我的應用程序時,腳本部分的工作非常完美。爭論腳本Python文件管理並不總是工作?

部分:

def correction():         # to implement the antenna 
                 # correction values 
    if abs(az_delta)<5 and abs(el_delta)<5: 
     azimc = az_delta 
     elevc = el_delta 
     conf_data = ""        # if we accept the 
          # corrections we need to save them for future use 
     input_file = open('acemedat.py', 'r') 
     for line in input_file: 
     if 'azcor =' in line: 
      line = 'azcor = ' + str(azimc) + '\r\n' 
     if 'elcor =' in line: 
      line = 'elcor = ' + str(elevc) + '\r\n' 
     conf_data += line 
     input_file.close() 
     output_file = open ('acemedat.py', 'w') 
     output_file.write(conf_data) 
     output_file.close() 
     az_cor.configure(text = str('%5.1f' % azimc)) 
     el_cor.configure(text = str('%5.1f' % elevc)) 
     message.configure(text="Correction values acknowledged and saved") 
    else: 
     message.configure(text="Correction denied: delta > 5 degrees") 
    clear_message.configure(state='normal') 
    return; 

在所有情況下else子句按預期工作。 我需要做些什麼來糾正這種情況? 在此先感謝, Harke

+0

工作目錄是否在啓動時運行腳本(並查找acmedat.py),與手動執行時相同? –

+1

嗯,我非常抱歉打擾你:經典的目錄問題。現在顯然已經解決了。非常感謝!哈克 –

+0

:) np。我給了它一個答案,所以你可以把它標記爲已解決。這樣問題就會被關閉。 –

回答

0

是啓動時的工作目錄,腳本在哪裏運行(並查找acmedat.py),與手動執行時相同?