Merge lp:~canonical-platform-qa/autopilot/fix_vuild_for_x_incl_datetime into lp:autopilot

Proposed by Christopher Lee
Status: Merged
Approved by: Max Brustkern
Approved revision: 575
Merged at revision: 573
Proposed branch: lp:~canonical-platform-qa/autopilot/fix_vuild_for_x_incl_datetime
Merge into: lp:autopilot
Diff against target: 125 lines (+14/-37)
5 files modified
autopilot/application/_launcher.py (+2/-0)
autopilot/introspection/types.py (+7/-30)
autopilot/tests/unit/test_platform.py (+2/-2)
debian/control (+1/-0)
docs/otto.py (+2/-5)
To merge this branch: bzr merge lp:~canonical-platform-qa/autopilot/fix_vuild_for_x_incl_datetime
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+279844@code.launchpad.net

Commit message

Fix build issues on Xenial. Incl. simplifying DateTime.

Description of the change

Fix build issues on Xenial. Incl. simplifying DateTime.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks good to me. There is no need to use the pytz specific localize or normalize methods here.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Max Brustkern (nuclearbob) wrote :

LGTM. I'm glad to see the sphinx fixes aren't super complicated.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/application/_launcher.py'
2--- autopilot/application/_launcher.py 2015-11-18 21:36:10 +0000
3+++ autopilot/application/_launcher.py 2015-12-08 04:20:49 +0000
4@@ -22,6 +22,8 @@
5 import fixtures
6 from gi.repository import GLib
7 try:
8+ from gi import require_version
9+ require_version('UbuntuAppLaunch', '2')
10 from gi.repository import UbuntuAppLaunch
11 except ImportError:
12 # Note: the renamed package is not in Trusty.
13
14=== modified file 'autopilot/introspection/types.py'
15--- autopilot/introspection/types.py 2014-10-22 20:43:01 +0000
16+++ autopilot/introspection/types.py 2015-12-08 04:20:49 +0000
17@@ -37,8 +37,9 @@
18
19 """
20
21+import pytz
22 from datetime import datetime, time, timedelta
23-from dateutil.tz import gettz, tzutc
24+from dateutil.tz import gettz
25
26 import dbus
27 import logging
28@@ -650,39 +651,15 @@
29 super(DateTime, self).__init__(*args, **kwargs)
30 # Using timedelta in this manner is a workaround so that we can support
31 # timestamps larger than the 32bit time_t limit on 32bit hardware.
32- # We then apply another workaround where timedelta doesn't apply
33- # daylight savings, so we need to work out the offsets for the
34- # localtime manually and apply them to give us the correct local time.
35+ # We then apply the timezone information to this to get the correct
36+ # datetime.
37 #
38 # Note. self[0] is a UTC timestamp
39- EPOCH = datetime(1970, 1, 1, tzinfo=tzutc())
40+ utc = pytz.timezone('UTC')
41+ EPOCH = datetime(1970, 1, 1, tzinfo=utc)
42 utc_dt = EPOCH + timedelta(seconds=self[0])
43
44- local_tzinfo = gettz()
45-
46- # Get the localtimes timezone offset (known as standard offset) by
47- # subtracting its dst offset (if any) from its utc offset.
48- # We apply this to the utc datetime object to get datetime object in
49- # localtime.
50- # (We will check (once we have a local datetime) if the time is in dst
51- # and make that adjustment then.)
52- utc_offset = local_tzinfo.utcoffset(utc_dt)
53- dst_offset = local_tzinfo.dst(utc_dt)
54- standard_offset = utc_offset - dst_offset
55-
56- # Create a local timezone aware datetime object from the utc_dt
57- # (i.e. attaching a timezone to it) and apply the standard offset to
58- # give us the local time.
59- local_dt = utc_dt.replace(tzinfo=local_tzinfo) + standard_offset
60-
61- # If the new local time is firmly in std time then the standard offset
62- # will be 0 (i.e. timedelta(0)).
63- # If the delta isn't 0 then we need to use the timezone information to
64- # apply the dst delta to the local time.
65- if standard_offset != timedelta(0):
66- local_dt = local_dt + local_tzinfo.dst(local_dt)
67-
68- self._cached_dt = local_dt
69+ self._cached_dt = utc_dt.astimezone(gettz())
70
71 @property
72 def year(self):
73
74=== modified file 'autopilot/tests/unit/test_platform.py'
75--- autopilot/tests/unit/test_platform.py 2014-07-23 03:37:24 +0000
76+++ autopilot/tests/unit/test_platform.py 2015-12-08 04:20:49 +0000
77@@ -39,7 +39,7 @@
78 @patch('autopilot.platform._PlatformDetector')
79 def test_model_creates_platform_detector(self, mock_detector):
80 platform.model()
81- mock_detector.create.assert_called_once()
82+ mock_detector.create.assert_called_once_with()
83
84 @patch('autopilot.platform._PlatformDetector._cached_detector')
85 def test_model_returns_correct_value(self, mock_detector):
86@@ -49,7 +49,7 @@
87 @patch('autopilot.platform._PlatformDetector')
88 def test_image_codename_creates_platform_detector(self, mock_detector):
89 platform.image_codename()
90- mock_detector.create.assert_called_once()
91+ mock_detector.create.assert_called_once_with()
92
93 @patch('autopilot.platform._PlatformDetector._cached_detector')
94 def test_image_codename_returns_correct_value(self, mock_detector):
95
96=== modified file 'debian/control'
97--- debian/control 2015-07-22 23:29:11 +0000
98+++ debian/control 2015-12-08 04:20:49 +0000
99@@ -30,6 +30,7 @@
100 python3-subunit,
101 python3-testscenarios,
102 python3-testtools,
103+ python3-tz,
104 python3-xlib (>=0.14+20091101-1ubuntu3),
105 sphinx-common,
106 texlive-latex-extra,
107
108=== modified file 'docs/otto.py'
109--- docs/otto.py 2013-07-25 05:47:36 +0000
110+++ docs/otto.py 2015-12-08 04:20:49 +0000
111@@ -56,12 +56,9 @@
112 self.content, self.lineno, self.content_offset,
113 self.block_text, self.state, self.state_machine)
114 image_container = nodes.container()
115- image_container.children.append(nodes.image(uri='/images/otto-64.png'))
116+ image_container.append(nodes.image(uri='/images/otto-64.png'))
117 image_container['classes'] = ['otto-image-container']
118 outer_container = nodes.container()
119- outer_container.children.extend(
120- [image_container]
121- + ad
122- )
123+ outer_container.extend([image_container] + ad)
124 outer_container['classes'] = ['otto-says-container']
125 return [outer_container]

Subscribers

People subscribed via source and target branches