Merge lp:~brian-murray/ubuntu-qa-tools/faster-help into lp:ubuntu-qa-tools

Proposed by Brian Murray
Status: Merged
Merged at revision: 1046
Proposed branch: lp:~brian-murray/ubuntu-qa-tools/faster-help
Merge into: lp:ubuntu-qa-tools
Diff against target: 65 lines (+7/-6)
1 file modified
vm-tools/uvt (+7/-6)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-qa-tools/faster-help
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Marc Deslauriers Pending
Review via email: mp+231652@code.launchpad.net

Description of the change

I was surprised at how long uvt help took to output information, and fixed it by moving around some imports to the functions in which they are used.

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Looks good to me.

Something which could be fixed independently is:

daniel@daydream:~/ubuntu-qa-tools$ pyflakes3 vm-tools/uvt
vm-tools/uvt:2628: undefined name 'raw_input'
daniel@daydream:~/ubuntu-qa-tools$

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'vm-tools/uvt'
2--- vm-tools/uvt 2014-05-13 20:42:35 +0000
3+++ vm-tools/uvt 2014-08-21 00:45:37 +0000
4@@ -19,19 +19,13 @@
5 # regenerated. Format is YYYYMMDD + 2 digit daily revision.
6 script_version="2014051301"
7
8-import hashlib
9 import optparse
10 import os
11-import pwd
12 import re
13-import shutil
14-import socket
15 import subprocess
16 import sys
17-import tempfile
18 import time
19 import xml.etree.ElementTree as ET
20-from urllib.request import urlopen
21
22 try:
23 import distro_info
24@@ -1485,6 +1479,7 @@
25
26 def ssh_connect(host):
27 '''Attempts a connection on port 22'''
28+ import socket
29 try:
30 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
31 s.connect((host, 22))
32@@ -1699,6 +1694,8 @@
33
34 def create_preseeded_iso(release_iso, cache, iso_type, vm_name, release,
35 ovmf=False):
36+ import shutil
37+ import tempfile
38 '''Adds preseed to iso'''
39
40 release_iso_preseed="vmtools-%s-%s" % (vm_name, release_iso)
41@@ -2495,6 +2492,7 @@
42 def download_file(url, filename):
43 '''Downloads a file from the web with a progress indicator'''
44
45+ from urllib.request import urlopen
46 try:
47 u = urlopen(url)
48 f = open(os.path.join(uvt_conf['vm_dir_iso'],filename), 'wb')
49@@ -2522,6 +2520,7 @@
50 def find_latest_release(release_num, iso_type):
51 '''Searches web for latest point release'''
52
53+ from urllib.request import urlopen
54 print("Searching web for latest point release...")
55 if iso_type == 'mini':
56 # FIXME: we should add logic to search for the latest mini release
57@@ -2898,6 +2897,8 @@
58 return results
59
60 def load_uvt_config():
61+ import hashlib
62+ import pwd
63 '''Read in config file'''
64
65 conf_file = os.path.join(os.path.expanduser("~"), config_file)