Merge remote-tracking branch 'derphilipp/master' into python3k

Conflicts:
	pyicloud/cmdline.py
This commit is contained in:
Adam Coddington 2014-10-25 20:34:27 -07:00
commit 77b17f091c
3 changed files with 45 additions and 16 deletions

View file

@ -4,6 +4,7 @@
A Command Line Wrapper to allow easy use of pyicloud for A Command Line Wrapper to allow easy use of pyicloud for
command line scripts, and related. command line scripts, and related.
""" """
from __future__ import print_function
import argparse import argparse
import pickle import pickle
import sys import sys
@ -185,19 +186,19 @@ def main(args=None):
contents = dev.content contents = dev.content
if command_line.longlist: if command_line.longlist:
print "-"*30 print("-"*30)
print contents["name"] print(contents["name"])
for x in contents: for x in contents:
print "%20s - %s" % (x, contents[x]) print("%20s - %s" % (x, contents[x]))
elif command_line.list: elif command_line.list:
print "-"*30 print("-"*30)
print "Name - %s" % contents["name"] print("Name - %s" % contents["name"])
print "Display Name - %s" % contents["deviceDisplayName"] print("Display Name - %s" % contents["deviceDisplayName"])
print "Location - %s" % contents["location"] print("Location - %s" % contents["location"])
print "Battery Level - %s" % contents["batteryLevel"] print("Battery Level - %s" % contents["batteryLevel"])
print "Battery Status- %s" % contents["batteryStatus"] print("Battery Status- %s" % contents["batteryStatus"])
print "Device Class - %s" % contents["deviceClass"] print("Device Class - %s" % contents["deviceClass"])
print "Device Model - %s" % contents["deviceModel"] print("Device Model - %s" % contents["deviceModel"])
# Play a Sound on a device # Play a Sound on a device
if command_line.sound: if command_line.sound:

View file

@ -1,7 +1,9 @@
from __future__ import absolute_import from __future__ import absolute_import
import os from datetime import datetime, timedelta
from datetime import datetime
from calendar import monthrange from calendar import monthrange
import time
import pytz
class CalendarService(object): class CalendarService(object):
@ -18,12 +20,37 @@ class CalendarService(object):
self._calendar_endpoint, self._calendar_endpoint,
) )
def get_all_possible_timezones_of_local_machine(self):
"""
Return all possible timezones in Olson TZ notation
This has been taken from
http://stackoverflow.com/questions/7669938
"""
local_names = []
if time.daylight:
local_offset = time.altzone
localtz = time.tzname[1]
else:
local_offset = time.timezone
localtz = time.tzname[0]
local_offset = timedelta(seconds=-local_offset)
for name in pytz.all_timezones:
timezone = pytz.timezone(name)
if not hasattr(timezone, '_tzinfos'):
continue
for (utcoffset, daylight, tzname), _ in timezone._tzinfos.items():
if utcoffset == local_offset and tzname == localtz:
local_names.append(name)
return local_names
def get_system_tz(self): def get_system_tz(self):
""" """
Retrieves the system's timezone. Retrieves the system's timezone from a list of possible options.
From: http://stackoverflow.com/a/7841417 Just take the first one
""" """
return '/'.join(os.readlink('/etc/localtime').split('/')[-2:]) return self.get_possible_timezones()[0]
def get_event_detail(self, pguid, guid): def get_event_detail(self, pguid, guid):
""" """

View file

@ -1,2 +1,3 @@
requests>=1.2 requests>=1.2
six six
pytz