Merge lp:~roadmr/checkbox/1329728-fix-xrandr-cycle into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Approved by: Daniel Manrique
Approved revision: 3115
Merged at revision: 3117
Proposed branch: lp:~roadmr/checkbox/1329728-fix-xrandr-cycle
Merge into: lp:checkbox
Diff against target: 108 lines (+45/-23)
1 file modified
providers/plainbox-provider-checkbox/bin/xrandr_cycle (+45/-23)
To merge this branch: bzr merge lp:~roadmr/checkbox/1329728-fix-xrandr-cycle
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+223444@code.launchpad.net

Commit message

    providers:checkbox: Fix template and exception handling in xrandr_cycle

    The script now looks for its template file in several locations, is more
    strict with exception handling, and provides better error messages if
    things don't work as expected.

    Due to bin/lib split in plainbox providers, it needs a bit of
    configuration to be run manually (i.e. from outside checkbox or
    plainbox), but the script will provide guidance on the environment
    variable to set for this to work.

Description of the change

    providers:checkbox: Fix template and exception handling in xrandr_cycle

    The script now looks for its template file in several locations, is more
    strict with exception handling, and provides better error messages if
    things don't work as expected.

    Due to bin/lib split in plainbox providers, it needs a bit of
    configuration to be run manually (i.e. from outside checkbox or
    plainbox), but the script will provide guidance on the environment
    variable to set for this to work.

To post a comment you must log in.
3082. By Zygmunt Krynicki

"automatic merge by tarmac [r=roadmr][bug=1092925][author=zkrynicki]"

3083. By Zygmunt Krynicki

"automatic merge by tarmac [r=roadmr][bug=1301227][author=zkrynicki]"

3084. By Daniel Manrique

"providers:plainbox: convert sleep_test to python3.

INcludes some pep8 fixes.

Note that I just did the overall conversion to ensure the script runs; however, since it depends on specific markers logged by the kernel in syslog, and those have changed in the past year, the script no longer works (it does suspend but then always outputs "fail"). Some more work is needed to identify marker strings and properly set state based on them.

 [r=zkrynicki][bug=1303941][author=roadmr]"

3085. By Daniel Manrique

"providers:checkbox: update usb3 testing jobs to use --driver

This is more reliable than checking for a specific threshold. [r=zkrynicki][bug=1331528][author=roadmr]"

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

launchpad u no save inline comments without this fussy textarea

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

and needs fixn'

review: Needs Fixing
3086. By Daniel Manrique

"providers:checkbox: Add device requirement for firewire tests [r=zkrynicki][bug=1305013][author=roadmr]"

3087. By Sylvain Pineau

"automatic merge by tarmac [r=sylvain-pineau][bug=1305640][author=sylvain-pineau]"

3088. By Po-Hsu Lin

"automatic merge by tarmac [r=roadmr][bug=1330399][author=cypressyew]"

3089. By Zygmunt Krynicki

"automatic merge by tarmac [r=roadmr][bug=][author=zkrynicki]"

3090. By Daniel Manrique

"checkbox-support:parsers:udev: Handle case where a candidate network device has no driver
 [r=zkrynicki][bug=1319757][author=roadmr]"

3091. By Po-Hsu Lin

"automatic merge by tarmac [r=zkrynicki][bug=1332476][author=cypressyew]"

3092. By Daniel Manrique

"make piglit/tarball less verbose. [r=zkrynicki][bug=1169875][author=roadmr]"

3093. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

3094. By Chris Gregan

"automatic merge by tarmac [r=roadmr][bug=][author=cgregan]"

3095. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

3096. By Daniel Manrique

"providers:checkbox: update graphics_driver to handle NULL display spec on some NVidia cards [r=zkrynicki][bug=1329607][author=roadmr]"

3097. By Chris Gregan

"automatic merge by tarmac [r=roadmr][bug=][author=cgregan]"

3098. By Ashley Lai

"automatic merge by tarmac [r=roadmr][bug=1328943][author=alai]"

3099. By Daniel Manrique

"The effective exit code of the script could potentially be "1", this forces the offending checks to end with "0" because we care about the text not the return code. [r=roadmr][bug=][author=roadmr]"

3100. By Po-Hsu Lin

"automatic merge by tarmac [r=roadmr][bug=][author=cypressyew]"

3101. By Daniel Manrique

"automatic merge by tarmac [r=roadmr][bug=1333956][author=roadmr]"

3102. By Jeff Lane 

"network script now determines max_speed from ethtool and link_speed from sys/class/net/DEV/speed for more accurate results. [r=roadmr][bug=1336320][author=bladernr]"

3103. By Daniel Manrique

"Fixes some problems with the network script (bug 1337537, a small problem with ethtool invocation, some minor string fixes). [r=bladernr][bug=1337537][author=roadmr]"

3104. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

3105. By Daniel Manrique

"checkbox-support:parsers:udevadm: Refine media card heuristics.

Per https://bugs.launchpad.net/checkbox-support/+bug/1337270, some SSD
hard drives have model names which made our card reader regular
expression mistake them for card readers (specifically the string mSATA
looked like a memory stick to our naive regex). This adds a simple
negative lookahead to ensure MS only matches if it's not followed
immediately by "ata". The regex is case-insensitive. [r=zkrynicki][bug=1337270][author=roadmr]"

3106. By Po-Hsu Lin

"automatic merge by tarmac [r=sylvain-pineau][bug=1331302][author=cypressyew]"

3107. By Sylvain Pineau

"automatic merge by tarmac [r=roadmr][bug=][author=sylvain-pineau]"

3108. By Sylvain Pineau

"automatic merge by tarmac [r=sylvain-pineau][bug=1331302][author=checkbox-dev]"

3109. By Daniel Manrique

"Fixes the requirement expression for power-management/tickless_idle. [r=bladernr][bug=1333624][author=roadmr]"

3110. By Chris Gregan

"automatic merge by tarmac [r=roadmr][bug=][author=cgregan]"

3111. By Mike Rushton

"added ipv6 support via bug 1013273 [r=roadmr][bug=1013273][author=leftyfb]"

3112. By Sylvain Pineau

"automatic merge by tarmac [r=sylvain-pineau][bug=][author=sylvain-pineau]"

3113. By Jeff Lane 

"automatic merge by tarmac [r=roadmr][bug=][author=bladernr]"

3114. By Daniel Manrique

providers:checkbox: Fix template and exception handling in xrandr_cycle

The script now looks for its template file in several locations, is more
strict with exception handling, and provides better error messages if
things don't work as expected.

Due to bin/lib split in plainbox providers, it needs a bit of
configuration to be run manually (i.e. from outside checkbox or
plainbox), but the script will provide guidance on the environment
variable to set for this to work.

3115. By Daniel Manrique

providers:checkbox: xrandr_cycle pep8 and assorted fixes

Revision history for this message
Daniel Manrique (roadmr) wrote :

Fixed and resubmitting. Some clarification is needed so this is potentially not ready yet. Let me know.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1, thanks

I'm still partially -1 on the 'cannot find .xml file' problem. I don't think our scripts should go all the way to getting that to work (we certainly don't do it consistently). Still, this is a system problem and you shouldn't need to fix it in this particular instance.

review: Approve
Revision history for this message
Daniel Manrique (roadmr) wrote :

Flipping the approve flag based on the previous comment (?)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'providers/plainbox-provider-checkbox/bin/xrandr_cycle'
2--- providers/plainbox-provider-checkbox/bin/xrandr_cycle 2014-03-20 14:01:58 +0000
3+++ providers/plainbox-provider-checkbox/bin/xrandr_cycle 2014-07-11 20:58:06 +0000
4@@ -1,13 +1,14 @@
5 #!/usr/bin/env python3
6
7+import argparse
8+import errno
9+import os
10+import re
11+import shutil
12 import subprocess
13-import argparse
14+import sys
15 import tarfile
16-import shutil
17 import time
18-import sys
19-import os
20-import re
21
22 parser = argparse.ArgumentParser()
23 parser.add_argument('--keyword', default='',
24@@ -68,7 +69,19 @@
25 # Now we have a list of the modes we need to test. So let's do just that.
26 profile_path = os.environ['HOME'] + '/.shutter/profiles/'
27 screenshot_path = os.path.join(args.screenshot_dir, 'xrandr_screens')
28-script_home = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
29+
30+# Where to find the shutter.xml template? Two possible locations.
31+shutter_xml_template = None
32+
33+if 'PLAINBOX_PROVIDER_DATA' in os.environ:
34+ shutter_xml_template = os.path.join(os.environ['PLAINBOX_PROVIDER_DATA'],
35+ "settings", "shutter.xml")
36+else:
37+ shutter_xml_template = os.path.join(os.path.split(os.path.dirname(
38+ os.path.realpath(__file__)))[0],
39+ "data",
40+ "settings",
41+ "shutter.xml")
42
43 if args.keyword:
44 screenshot_path = screenshot_path + '_' + args.keyword
45@@ -76,21 +89,27 @@
46 regex = re.compile(r'filename="[^"\r\n]*"')
47
48 # Keep the shutter profile in place before starting
49-try:
50- os.makedirs(profile_path)
51-except OSError:
52- pass
53-
54-try:
55- os.makedirs(screenshot_path)
56-except OSError:
57- pass
58-
59-try:
60- shutil.copy(script_home + '/data/settings/shutter.xml',
61- profile_path)
62-except IOError:
63- pass
64+
65+# Any errors creating the directories or copying the template is fatal,
66+# since things won't work if we fail.
67+try:
68+ os.makedirs(profile_path, exist_ok=True)
69+ os.makedirs(screenshot_path, exist_ok=True)
70+except OSError as excp:
71+ raise SystemExit("ERROR: Unable to create "
72+ "required directories: {}".format(excp))
73+
74+try:
75+ shutil.copy(shutter_xml_template, profile_path)
76+except (IOError, OSError) as excp:
77+ print("ERROR: Unable to copy {} to {}: {}".format(shutter_xml_template,
78+ profile_path,
79+ excp))
80+ if excp.errno == errno.ENOENT:
81+ print("Try setting PLAINBOX_PROVIDER_DATA to the the data path of a")
82+ print("provider shipping the 'shutter.xml' template file, usually ")
83+ print("found under /usr/share.")
84+ raise SystemExit()
85
86 try:
87 old_profile = open(profile_path + 'shutter.xml', 'r')
88@@ -102,7 +121,8 @@
89 new_profile.close()
90 old_profile.close()
91 except:
92- pass
93+ raise SystemExit("ERROR: While updating folder name "
94+ "in shutter profile: {}".format(sys.exc_info()))
95
96 for mode in modes:
97 cmd = 'xrandr --output ' + mode[0] + ' --mode ' + mode[1]
98@@ -134,7 +154,9 @@
99 except:
100 print("""Could not configure screenshot tool -
101 you may need to install the package 'shutter',
102- or check that %s exists.""" % profile_path)
103+ or check that {}/{} exists and is writable.""".format(
104+ profile_path,
105+ 'shutter.xml'))
106
107 message = 'Set mode ' + mode[1] + ' for output ' + mode[0]
108 success_messages.append(message)

Subscribers

People subscribed via source and target branches