From 14c657fd69c689299a01b2dacdfbf7a1e3a3957b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Tue, 17 Jan 2017 01:01:08 +0000 Subject: freestyle: error out if hidraw device does not exist. This avoids creating a binary file when running the tool as root (bad Flameeyes). --- glucometerutils/support/freestyle.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'glucometerutils/support') diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py index 9857086..307cf64 100644 --- a/glucometerutils/support/freestyle.py +++ b/glucometerutils/support/freestyle.py @@ -12,6 +12,7 @@ __license__ = 'MIT' import csv import datetime +import os.path import re import struct @@ -68,6 +69,9 @@ class FreeStyleHidDevice(object): TEXT_REPLY_CMD = 0x60 def __init__(self, device): + if not os.path.exists(device): + raise exceptions.ConnectionFailed( + message='Path %s does not exist.' % device) self.handle_ = open(device, 'w+b') def connect(self): -- cgit v1.2.3