Skip to content

Commit a17005c

Browse files
authored
Merge pull request #151 from jkoelker/master
PyPi Test Deploy v4.0.3
2 parents 7345fc6 + 4222c4e commit a17005c

File tree

6 files changed

+135
-52
lines changed

6 files changed

+135
-52
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ nosetests.xml
4040
MANIFEST
4141

4242
# PyCharm
43-
.idea/*
43+
.idea
44+
45+
# VS Code
46+
.vscode

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ Command line
223223
224224
usage: nest [-h] [--conf FILE] [--token-cache TOKEN_CACHE_FILE] [-t TOKEN]
225225
[--client-id ID] [--client-secret SECRET] [-k] [-c] [-s SERIAL]
226-
[-S STRUCTURE] [-i INDEX]
226+
[-S STRUCTURE] [-i INDEX] [-v]
227227
{temp,fan,mode,away,target,humid,target_hum,show,camera-show,camera-streaming,protect-show}
228228
...
229229
230230
Command line interface to Nest™ Thermostats
231231
232232
positional arguments:
233-
{temp,fan,mode,away,target,humid,target_hum,show,camera-show,camera-streaming,protect-show}
233+
{temp,fan,mode,away,target,humid,target_hum,show,camera-show,camera-streaming,protect-show}
234234
command help
235235
temp show/set temperature
236236
fan set fan "on" or "auto"
@@ -265,6 +265,7 @@ Command line
265265
actions
266266
-i INDEX, --index INDEX
267267
optional, specify index number of nest to talk to
268+
-v, --verbose showing verbose logging
268269
269270
examples:
270271
# If your nest is not in range mode

nest/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# -*- coding:utf-8 -*-
2+
import logging
23

34
from .nest import Nest
45

56
from .utils import CELSIUS
67
from .utils import FAHRENHEIT
78

9+
logging.getLogger(__name__).addHandler(logging.NullHandler())
10+
811
__all__ = ['CELSIUS', 'FAHRENHEIT', 'Nest']

nest/command_line.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import argparse
1111
import datetime
12+
import logging
1213
import os
1314
import sys
1415
import errno
@@ -76,6 +77,10 @@ def get_parser():
7677
help='optional, specify index number of nest to '
7778
'talk to')
7879

80+
parser.add_argument('-v', '--verbose', dest='verbose',
81+
action='store_true',
82+
help='showing verbose logging')
83+
7984
subparsers = parser.add_subparsers(dest='command',
8085
help='command help')
8186
temp = subparsers.add_parser('temp', help='show/set temperature')
@@ -298,6 +303,17 @@ def main():
298303
parser = get_parser()
299304
args = parser.parse_args()
300305

306+
if args.verbose:
307+
logger = logging.getLogger('nest')
308+
logger.setLevel(logging.DEBUG)
309+
console_handler = logging.StreamHandler()
310+
formatter = logging.Formatter(
311+
"%(asctime)s %(levelname)s (%(threadName)s) "
312+
"[%(name)s] %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
313+
console_handler.setFormatter(formatter)
314+
console_handler.setLevel(logging.DEBUG)
315+
logger.addHandler(console_handler)
316+
301317
# This is the command(s) passed to the command line utility
302318
cmd = args.command
303319
if cmd is None:

0 commit comments

Comments
 (0)