Thor77 / Blueproximity

Run a command once a bluetooth device is in/out of a range
GNU General Public License v2.0
66 stars 15 forks source link

error line 1274 #41

Open Thor77 opened 7 years ago

Thor77 commented 7 years ago

$ start_proximity.sh Traceback (most recent call last): File "proximity.py", line 1274, in <module> config = ConfigObj(os.path.join(confdir, ('standard') + '.conf'),{'create_empty':True,'configspec':conf_specs}) File "/usr/lib/python2.6/site-packages/configobj.py", line 1206, in init DeprecationWarning, stacklevel=2) TypeError: warn() takes at most 3 arguments (4 given)

installed: extra/bluez 4.59-1 Libraries and tools for the Bluetooth protocol stack local/bluez-python 0.1.4-1 A BlueZ python binding on top of dbus-python community/python-pybluez 0.18-1 Python wrapper for the BlueZ Bluetooth stack extra/python 2.6.4-1 A high-level scripting language

Thor77 commented 7 years ago

So I went back and checked about python-configobj-4.6.0 and my previous comment does work for this version too. I also tested adding the ** as the deprecated message referred to and this also works for both versions. The real question now is should the call be changed to the new format or should the deprecated method be used.

line 1260 config = ConfigObj(os.path.join(conf_dir,filename),**{'create_empty':False,'file_error':True,'configspec':conf_specs}) Or config = ConfigObj(infile=os.path.join(conf_dir,filename),create_empty=True,file_error=False,configspec=conf_specs)

line 1274 config = ConfigObj(os.path.join(confdir, ('standard') + '.conf'),**{'create_empty':True,'file_error':False,'configspec':conf_specs}) or config = ConfigObj(infile=os.path.join(confdir, ('standard') + '.conf'),create_empty=True,file_error=False,configspec=conf_specs)

Also these two lines are for loading a new config file or and existing one. So depending if you have a config file exists or not, you get a error on line 1260 or 1274. The line 1274 is the new file load. (By jagee)

Thor77 commented 7 years ago

So I have not tracked this completely down but this may be related to a change in python-configobj. When I upgraded to F13 this broke for me. I was using python-configobj-4.6.0-2.fc12.noarch but and now using the newer python-configobj-4.7.0-2.fc13.noarch library.

http://www.voidspace.org.uk/python/configobj.html

"New in ConfigObj 4.7.0: Instantiating ConfigObj with an options dictionary is now deprecated. To modify code that used to do this simply unpack the dictionary in the constructor call: config = ConfigObj(filename, **options)"

I was able to get it working again by changing the following in proximity.py

line 1260 config = ConfigObj(os.path.join(conf_dir,filename),{'create_empty':False,'file_error':True,'configspec':conf_specs})

changed to config = ConfigObj(infile=os.path.join(conf_dir,filename),create_empty=True,file_error=False,configspec=conf_specs)

line 1274 config = ConfigObj(os.path.join(confdir, ('standard') + '.conf'),{'create_empty':True,'file_error':False,'configspec':conf_specs})

change to config = ConfigObj(infile=os.path.join(confdir, ('standard') + '.conf'),create_empty=True,file_error=False,configspec=conf_specs)

Not sure if this will cause errors on the older python-configobj-4.6.0 code? (By jagee)

Thor77 commented 7 years ago

Error after update of python-configobj to version 4.7.0-1:

File "proximity.py", line 1274, in <module> config = ConfigObj(os.path.join(confdir, ('standard') + '.conf'),{'create_empty':True,'file_error':False,'configspec':conf_specs}) File "/usr/lib/python2.6/site-packages/configobj.py", line 1206, in init DeprecationWarning, stacklevel=2) TypeError: warn() takes at most 3 arguments (4 given)

Consulting the configobj-specifications:

http://www.voidspace.org.uk/python/configobj.html\#configobj-specifications

results in an easy fix:

--- proximity.py 2008-02-28 16:59:01.000000000 +0100 +++ /usr/bin/proximity.py 2010-01-18 22:54:51.346179032 +0100

@@ -111,3 +111,3 @@ pass -if (IMPORT_BT!=2): +if (IMPORTBT!=3): print ("The program cannot import the module bluetooth.") @@ -1259,3 +1259,3 @@

add every valid .conf file to the array of configs