summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
79f4383)
as suggested in http://stackoverflow.com/questions/
10840533/most-pythonic-way-to-delete-a-file-which-may-not-exist
-import time, socket, os, stat, atexit
+import time, socket, os, stat, atexit, errno
from datetime import datetime
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
from datetime import datetime
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
# delete a file, don't care if it did not exist in the first place
def forcerm(name):
# delete a file, don't care if it did not exist in the first place
def forcerm(name):
- if os.path.exists(name):
+ except OSError as e:
+ # only ignore error if it was "file didn't exist"
+ if e.errno != errno.ENOENT:
+ raise
# commands: on a pin do a series of timed on/off switches
class Pinoutput:
# commands: on a pin do a series of timed on/off switches
class Pinoutput: