pymacadmin icon indicating copy to clipboard operation
pymacadmin copied to clipboard

Seeing a backtrace

Open GoogleCodeExporter opened this issue 10 years ago • 3 comments

Oct  2 04:29:02 pluto org.crankd.plist[58620]: INFO: NSWorkspace Notification 
NSWorkspaceDidWakeNotification: executing /bin/echo "The system woke from 
sleep!"
Oct  2 04:29:02 pluto org.crankd.plist[58620]: Traceback (most recent call 
last):
Oct  2 04:29:02 pluto org.crankd.plist[58620]:   File 
"/usr/local/sbin/crankd.py", line 597, in <module>
Oct  2 04:29:02 pluto org.crankd.plist[58620]:     main()
Oct  2 04:29:02 pluto org.crankd.plist[58620]:   File 
"/usr/local/sbin/crankd.py", line 523, in main
Oct  2 04:29:02 pluto org.crankd.plist[58620]:     
AppHelper.runConsoleEventLoop(installInterrupt=True)
Oct  2 04:29:02 pluto org.crankd.plist[58620]:   File 
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyOb
jC/PyObjCTools/AppHelper.py", line 178, in runConsoleEventLoop
Oct  2 04:29:02 pluto org.crankd.plist[58620]:     if not 
runLoop.runMode_beforeDate_(mode, nextfire):
Oct  2 04:29:02 pluto org.crankd.plist[58620]:   File 
"/usr/local/sbin/crankd.py", line 110, in onNotification_
Oct  2 04:29:02 pluto org.crankd.plist[58620]:     
self.callable(user_info=user_info) # pylint: disable-msg=E1101
Oct  2 04:29:02 pluto org.crankd.plist[58620]:   File 
"/usr/local/sbin/crankd.py", line 558, in do_shell
Oct  2 04:29:02 pluto org.crankd.plist[58620]:     for k, v in 
kwargs['user_info'].items():
Oct  2 04:29:02 pluto org.crankd.plist[58620]: AttributeError: 'NoneType' 
object has no attribute 'items'

Original issue reported on code.google.com by [email protected] on 2 Oct 2011 at 8:36

GoogleCodeExporter avatar Mar 13 '15 15:03 GoogleCodeExporter

I'm no python expert, but I inserted a line as follows and it works.


$ diff -Naur crankd.py.orig crankd.py
--- crankd.py.orig  2012-01-11 21:01:38.000000000 +0800
+++ crankd.py   2012-01-11 20:30:16.000000000 +0800
@@ -557,8 +557,9 @@
             child_env['CRANKD_%s' % k.upper()] = str(kwargs[k])

     if 'user_info' in kwargs:
-   for k, v in kwargs['user_info'].items():
-       child_env[create_env_name(k)] = str(v)
+        if kwargs['user_info'] is not None:
+       for k, v in kwargs['user_info'].items():
+           child_env[create_env_name(k)] = str(v)

     try:
         rc = call(command, shell=True, env=child_env)

Original comment by [email protected] on 11 Jan 2012 at 1:02

GoogleCodeExporter avatar Mar 13 '15 15:03 GoogleCodeExporter

in that case I think the right fix is to replace `if 'user_info' in kwargs` 
with `if kwargs.get('user_info')`.

Original comment by [email protected] on 11 Jan 2012 at 1:13

GoogleCodeExporter avatar Mar 13 '15 15:03 GoogleCodeExporter

I went with something similar to handle the case where user_info is present but 
None: 

https://github.com/acdha/pymacadmin/commit/533b6c4c4379f0632e2fdebfbe115f9880cb4
cab

Original comment by [email protected] on 11 Jan 2012 at 1:42

GoogleCodeExporter avatar Mar 13 '15 15:03 GoogleCodeExporter