[139128] trunk/dports/science/uhd

michaelld at macports.org michaelld at macports.org
Mon Aug 3 08:42:41 PDT 2015


Revision: 139128
          https://trac.macports.org/changeset/139128
Author:   michaelld at macports.org
Date:     2015-08-03 08:42:41 -0700 (Mon, 03 Aug 2015)
Log Message:
-----------
uhd:
+ update devel to 0c7d748b (20150730);
+ remove integrated patch;
+ add temporary patches to fix B2x0 USB access.

Modified Paths:
--------------
    trunk/dports/science/uhd/Portfile

Added Paths:
-----------
    trunk/dports/science/uhd/files/patch-b200-fix_initial_loading.diff
    trunk/dports/science/uhd/files/patch-b200-fixes-LIBUSB_ERROR_PIPE-on-OS-X.diff

Removed Paths:
-------------
    trunk/dports/science/uhd/files/patch-host_utils_uhd_images_downloader.py.in.diff

Modified: trunk/dports/science/uhd/Portfile
===================================================================
--- trunk/dports/science/uhd/Portfile	2015-08-03 15:39:55 UTC (rev 139127)
+++ trunk/dports/science/uhd/Portfile	2015-08-03 15:42:41 UTC (rev 139128)
@@ -47,11 +47,17 @@
 
     name            uhd-devel
     conflicts       uhd
-    github.setup    EttusResearch uhd 012381d999c4a895593412aaf06e73432b458810
-    version         20150714
-    checksums       rmd160 450a9619d127533574f8848de6e7ce17beefb1cf \
-                    sha256 d3f26e8cfa7147df99f383a53f41340ff646bd202d748aa487da2a1befac0292
+    github.setup    EttusResearch uhd 0c7d748bbf6c282d3f1c759201e40f35f26133ca
+    version         20150730
+    checksums       rmd160 250ed5a0480f232d9ea07db82473345d20b3e0b2 \
+                    sha256 707ea2ff2fa49b5999d9693ba44049d6b60288137e6d6acf3fe2d5125e5329ad
 
+    # temporary patch to fix startup USB errors
+
+    patchfiles-append \
+        patch-b200-fixes-LIBUSB_ERROR_PIPE-on-OS-X.diff \
+        patch-b200-fix_initial_loading.diff
+
     # overload the github livecheck URL with the maint branch,
     # when it is more advanced; comment out for master.
 
@@ -170,10 +176,6 @@
 
 }
 
-# patch the UHD images downloader to work with both Python 2.7 & 3.4.
-
-patchfiles-append patch-host_utils_uhd_images_downloader.py.in.diff
-
 set PythonVersionWithDot [join [split ${PythonVersionNoDot} ""] "."]
 
 # required Python

Added: trunk/dports/science/uhd/files/patch-b200-fix_initial_loading.diff
===================================================================
--- trunk/dports/science/uhd/files/patch-b200-fix_initial_loading.diff	                        (rev 0)
+++ trunk/dports/science/uhd/files/patch-b200-fix_initial_loading.diff	2015-08-03 15:42:41 UTC (rev 139128)
@@ -0,0 +1,21 @@
+--- host/lib/usrp/b200/b200_impl.cpp.orig
++++ host/lib/usrp/b200/b200_impl.cpp
+@@ -125,8 +125,7 @@ static device_addrs_t b200_find(const device_addr_t &hint)
+     // so that re-enumeration after fw load can occur successfully.
+     // This requirement is a courtesy of libusb1.0 on windows.
+     size_t found = 0;
+-    std::vector<usb_device_handle::sptr> b200_device_handles = get_b200_device_handles(hint);
+-    BOOST_FOREACH(usb_device_handle::sptr handle, b200_device_handles) {
++    BOOST_FOREACH(usb_device_handle::sptr handle, get_b200_device_handles(hint)) {
+         //extract the firmware path for the b200
+         std::string b200_fw_image;
+         try{
+@@ -157,7 +156,7 @@ static device_addrs_t b200_find(const device_addr_t &hint)
+     //search for the device until found or timeout
+     while (boost::get_system_time() < timeout_time and b200_addrs.empty() and found != 0)
+     {
+-        BOOST_FOREACH(usb_device_handle::sptr handle, b200_device_handles)
++        BOOST_FOREACH(usb_device_handle::sptr handle, get_b200_device_handles(hint))
+         {
+             usb_control::sptr control;
+             try{control = usb_control::make(handle, 0);}

Added: trunk/dports/science/uhd/files/patch-b200-fixes-LIBUSB_ERROR_PIPE-on-OS-X.diff
===================================================================
--- trunk/dports/science/uhd/files/patch-b200-fixes-LIBUSB_ERROR_PIPE-on-OS-X.diff	                        (rev 0)
+++ trunk/dports/science/uhd/files/patch-b200-fixes-LIBUSB_ERROR_PIPE-on-OS-X.diff	2015-08-03 15:42:41 UTC (rev 139128)
@@ -0,0 +1,273 @@
+--- host/include/uhd/exception.hpp.orig
++++ host/include/uhd/exception.hpp
+@@ -98,6 +98,14 @@ namespace uhd{
+         virtual void dynamic_throw(void) const;
+     };
+ 
++    struct UHD_API usb_error : runtime_error{
++        int _code;
++        usb_error(int code, const std::string &what);
++        virtual unsigned code(void) const;
++        virtual usb_error *dynamic_clone(void) const;
++        virtual void dynamic_throw(void) const;
++    };
++
+     struct UHD_API not_implemented_error : runtime_error{
+         not_implemented_error(const std::string &what);
+         virtual unsigned code(void) const;
+--- host/lib/exception.cpp.orig
++++ host/lib/exception.cpp
+@@ -38,8 +38,15 @@ make_exception_impl("KeyError",              key_error,               lookup_err
+ make_exception_impl("TypeError",             type_error,              exception)
+ make_exception_impl("ValueError",            value_error,             exception)
+ make_exception_impl("RuntimeError",          runtime_error,           exception)
++//make_exception_impl("USBError",              usb_error,           runtime_error)
+ make_exception_impl("NotImplementedError",   not_implemented_error,   runtime_error)
+ make_exception_impl("EnvironmentError",      environment_error,       exception)
+ make_exception_impl("IOError",               io_error,                environment_error)
+ make_exception_impl("OSError",               os_error,                environment_error)
+ make_exception_impl("SystemError",           system_error,            exception)
++
++usb_error::usb_error(int code, const std::string &what):
++    runtime_error(str(boost::format("%s %d: %s") % "USBError" % code % what)){_code = code;}
++unsigned usb_error::code(void) const{return _code;} \
++usb_error *usb_error::dynamic_clone(void) const{return new usb_error(*this);} \
++void usb_error::dynamic_throw(void) const{throw *this;}
+--- host/lib/transport/libusb1_zero_copy.cpp.orig
++++ host/lib/transport/libusb1_zero_copy.cpp
+@@ -155,7 +155,7 @@ public:
+         result.is_recv = _is_recv;
+ #endif
+         const int ret = libusb_submit_transfer(_lut);
+-        if (ret != 0) throw uhd::runtime_error(str(boost::format(
++        if (ret != 0) throw uhd::usb_error(ret, str(boost::format(
+             "usb %s submit failed: %s") % _name % libusb_error_name(ret)));
+     }
+ 
+@@ -266,17 +266,26 @@ public:
+             _all_luts.push_back(lut);
+         }
+ 
+-        //initial release for all buffers
+-        for (size_t i = 0; i < get_num_frames(); i++)
++        size_t i = 0;
++        //try
+         {
+-            libusb_zero_copy_mb &mb = *(_mb_pool[i]);
+-            if (is_recv) mb.release();
+-            else
++            //initial release for all buffers
++            for (; i < get_num_frames(); i++)
+             {
+-                mb.result.completed = 1;
+-                _enqueued.push_back(&mb);
++                //UHD_MSG(status) << "Releasing " << i << std::endl;
++                libusb_zero_copy_mb &mb = *(_mb_pool[i]);
++                if (is_recv) mb.release();
++                else
++                {
++                    mb.result.completed = 1;
++                    _enqueued.push_back(&mb);
++                }
+             }
+         }
++        //catch (uhd::runtime_error& e)
++        {
++        //    UHD_MSG(status) << "Releasing " << i << ":" << e.what() << std::endl;
++        }
+     }
+ 
+     ~libusb_zero_copy_single(void)
+--- host/lib/usrp/b200/b200_impl.cpp.orig
++++ host/lib/usrp/b200/b200_impl.cpp
+@@ -37,6 +37,9 @@
+ #include <ctime>
+ #include <cmath>
+ 
++#include <uhd/transport/usb_zero_copy.hpp>
++#include "../../transport/libusb1_base.hpp"
++
+ using namespace uhd;
+ using namespace uhd::usrp;
+ using namespace uhd::transport;
+@@ -194,7 +197,44 @@ static device_addrs_t b200_find(const device_addr_t &hint)
+  **********************************************************************/
+ static device::sptr b200_make(const device_addr_t &device_addr)
+ {
+-    return device::sptr(new b200_impl(device_addr));
++    b200_impl* p = NULL;
++
++    for (int i = 0; i < 2; ++i)
++    {
++        p = new b200_impl();
++        int ret;
++        
++        ret = p->make(device_addr);
++        if (ret == LIBUSB_SUCCESS)
++            break;
++
++        {
++            libusb::device_handle::sptr dev_handle(libusb::device_handle::get_cached_handle(
++                boost::static_pointer_cast<libusb::special_handle>(p->get_handle())->get_device()
++            ));
++
++            ret = libusb_clear_halt(dev_handle->get(), 8 | 0x80);
++            UHD_MSG(status) << "Ctrl Recv clear: " << libusb_error_name(ret) << std::endl;
++            ret = libusb_clear_halt(dev_handle->get(), 4 | 0x00);
++            UHD_MSG(status) << "Ctrl Send clear: " << libusb_error_name(ret) << std::endl;
++
++            ret = libusb_clear_halt(dev_handle->get(), 6 | 0x80);
++            UHD_MSG(status) << "Data Recv clear: " << libusb_error_name(ret) << std::endl;
++            ret = libusb_clear_halt(dev_handle->get(), 2 | 0x00);
++            UHD_MSG(status) << "Data Send clear: " << libusb_error_name(ret) << std::endl;
++
++            ret = libusb_reset_device(dev_handle->get());
++            UHD_MSG(status) << "Dev Reset: " << libusb_error_name(ret) << std::endl;
++        }
++
++        delete p;
++        p = NULL;
++    }
++
++    if (p == NULL)
++        throw uhd::runtime_error("USB error");
++
++    return device::sptr(p);
+ }
+ 
+ UHD_STATIC_BLOCK(register_b200_device)
+@@ -205,10 +245,14 @@ UHD_STATIC_BLOCK(register_b200_device)
+ /***********************************************************************
+  * Structors
+  **********************************************************************/
+-b200_impl::b200_impl(const device_addr_t &device_addr) :
++b200_impl::b200_impl(void) :
+     _revision(0),
+     _tick_rate(0.0) // Forces a clock initialization at startup
+ {
++}
++
++int b200_impl::make(const uhd::device_addr_t& device_addr)
++{
+     _tree = property_tree::make();
+     _type = device::USRP;
+     const fs_path mb_path = "/mboards/0";
+@@ -262,17 +306,17 @@ b200_impl::b200_impl(const device_addr_t &device_addr) :
+     std::vector<usb_device_handle::sptr> device_list = usb_device_handle::get_device_list(vid_pid_pair_list);
+ 
+     //locate the matching handle in the device list
+-    usb_device_handle::sptr handle;
++    //usb_device_handle::sptr _handle;
+     BOOST_FOREACH(usb_device_handle::sptr dev_handle, device_list) {
+         if (dev_handle->get_serial() == device_addr["serial"]){
+-            handle = dev_handle;
++            _handle = dev_handle;
+             break;
+         }
+     }
+-    UHD_ASSERT_THROW(handle.get() != NULL); //better be found
++    UHD_ASSERT_THROW(_handle.get() != NULL); //better be found
+ 
+     //create control objects
+-    usb_control::sptr control = usb_control::make(handle, 0);
++    usb_control::sptr control = usb_control::make(_handle, 0);
+     _iface = b200_iface::make(control);
+     this->check_fw_compat(); //check after making
+ 
+@@ -360,12 +404,22 @@ b200_impl::b200_impl(const device_addr_t &device_addr) :
+     ctrl_xport_args["send_frame_size"] = min_frame_size;
+     ctrl_xport_args["num_send_frames"] = "16";
+ 
+-    _ctrl_transport = usb_zero_copy::make(
+-        handle,
+-        4, 8, //interface, endpoint
+-        3, 4, //interface, endpoint
+-        ctrl_xport_args
+-    );
++    UHD_MSG(status) << "Creating ctrl transport..." << std::endl;
++    try
++    {
++        _ctrl_transport = usb_zero_copy::make(
++            _handle,
++            4, 8, //interface, endpoint
++            3, 4, //interface, endpoint
++            ctrl_xport_args
++        );
++    }
++    catch (const uhd::usb_error& e)
++    {
++        UHD_MSG(status) << e.what() << std::endl;
++        return e.code();
++    }
++    UHD_MSG(status) << "Flusing ctrl recv buff..." << std::endl;
+     while (_ctrl_transport->get_recv_buff(0.0)){} //flush ctrl xport
+     _tree->create<double>(mb_path / "link_max_rate").set((usb_speed == 3) ? B200_MAX_RATE_USB3 : B200_MAX_RATE_USB2);
+ 
+@@ -442,12 +496,22 @@ b200_impl::b200_impl(const device_addr_t &device_addr) :
+     data_xport_args["send_frame_size"] = device_addr.get("send_frame_size", "8192");
+     data_xport_args["num_send_frames"] = device_addr.get("num_send_frames", "16");
+ 
+-    _data_transport = usb_zero_copy::make(
+-        handle,        // identifier
+-        2, 6,          // IN interface, endpoint
+-        1, 2,          // OUT interface, endpoint
+-        data_xport_args    // param hints
+-    );
++    UHD_MSG(status) << "Creating data transport..." << std::endl;
++    try
++    {
++        _data_transport = usb_zero_copy::make(
++            _handle,        // identifier
++            2, 6,          // IN interface, endpoint
++            1, 2,          // OUT interface, endpoint
++            data_xport_args    // param hints
++        );
++    }
++    catch (const uhd::usb_error& e)
++    {
++        UHD_MSG(status) << e.what() << std::endl;
++        return e.code();
++    }
++    UHD_MSG(status) << "Flusing data recv buff..." << std::endl;
+     while (_data_transport->get_recv_buff(0.0)){} //flush ctrl xport
+     _demux = recv_packet_demuxer_3000::make(_data_transport);
+ 
+@@ -624,6 +688,9 @@ b200_impl::b200_impl(const device_addr_t &device_addr) :
+         _tree->access<std::string>(mb_path / "time_source/value").set("internal");
+     }
+ 
++    _handle.reset();
++
++    return LIBUSB_SUCCESS;
+ }
+ 
+ b200_impl::~b200_impl(void)
+--- host/lib/usrp/b200/b200_impl.hpp.orig
++++ host/lib/usrp/b200/b200_impl.hpp
+@@ -91,9 +91,13 @@ class b200_impl : public uhd::device
+ {
+ public:
+     //structors
+-    b200_impl(const uhd::device_addr_t &);
++    b200_impl(void);
+     ~b200_impl(void);
+ 
++    int make(const uhd::device_addr_t &);
++    uhd::transport::usb_device_handle::sptr get_handle(void) const
++    { return _handle; }
++
+     //the io interface
+     uhd::rx_streamer::sptr get_rx_stream(const uhd::stream_args_t &args);
+     uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args);
+@@ -107,6 +111,8 @@ public:
+     void check_streamer_args(const uhd::stream_args_t &args, double tick_rate, const std::string &direction = "");
+ 
+ private:
++    uhd::transport::usb_device_handle::sptr _handle;
++
+     b200_type_t _b200_type;
+     size_t      _revision;
+ 
+-- 
+2.3.1
+

Deleted: trunk/dports/science/uhd/files/patch-host_utils_uhd_images_downloader.py.in.diff
===================================================================
--- trunk/dports/science/uhd/files/patch-host_utils_uhd_images_downloader.py.in.diff	2015-08-03 15:39:55 UTC (rev 139127)
+++ trunk/dports/science/uhd/files/patch-host_utils_uhd_images_downloader.py.in.diff	2015-08-03 15:42:41 UTC (rev 139128)
@@ -1,362 +0,0 @@
---- host/utils/uhd_images_downloader.py.in.orig
-+++ host/utils/uhd_images_downloader.py.in
-@@ -1,6 +1,6 @@
- #!/usr/bin/env python
- #
--# Copyright 2012-2014 Ettus Research LLC
-+# Copyright 2012-2015 Ettus Research LLC
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
-@@ -23,7 +23,7 @@ import math
- import traceback
- import shutil
- import hashlib
--import urllib2
-+import requests
- import zipfile
- 
- from optparse import OptionParser
-@@ -47,8 +47,8 @@ def md5Checksum(filePath):
-                     break
-                 m.update(data)
-             return m.hexdigest()
--    except Exception, e:
--        print "Failed to calculated MD5 sum of: %s (%s)" % (filePath, e)
-+    except Exception as e:
-+        print("Failed to calculated MD5 sum of: %s (%s)" % (filePath, e))
-         raise e
- 
- _checksum_fns = {
-@@ -60,16 +60,16 @@ class temporary_directory():
-         try:
-             self.name = tempfile.mkdtemp()
-             return self.name
--        except Exception, e:
--            print "Failed to create a temporary directory (%s)" % (e)
-+        except Exception as e:
-+            print("Failed to create a temporary directory (%s)" % (e))
-             raise e
- 
-     # Can return 'True' to suppress incoming exception
-     def __exit__(self, type, value, traceback):
-         try:
-             shutil.rmtree(self.name)
--        except Exception, e:
--            print "Could not delete temporary directory: %s (%s)" % (self.name, e)
-+        except Exception as e:
-+            print("Could not delete temporary directory: %s (%s)" % (self.name, e))
- 
- class uhd_images_downloader():
-     def __init__(self):
-@@ -77,25 +77,20 @@ class uhd_images_downloader():
- 
-     def download(self, images_url, filename, buffer_size=_DEFAULT_BUFFER_SIZE, print_progress=False):
-         """ Run the download, show progress """
--        opener = urllib2.build_opener()
--        opener.add_headers = [('User-Agent', 'UHD Images Downloader')]
--        u = opener.open(images_url)
--        meta = u.info()
--        filesize = float(meta.getheaders("Content-Length")[0])
-+        r = requests.get(images_url, stream=True, headers={'User-Agent': 'UHD Images Downloader'})
-+        filesize = float(r.headers['content-length'])
-         filesize_dl = 0
-         with open(filename, "wb") as f:
--            while True:
--                buff = u.read(buffer_size)
--                if not buff:
--                    break
--                f.write(buff)
--                filesize_dl += len(buff)
-+            for buff in r.iter_content(chunk_size=buffer_size):
-+                if buff:
-+                    f.write(buff)
-+                    filesize_dl += len(buff)
-                 if print_progress:
-                     status = r"%05d kB / %05d kB (%03d%%)" % (int(math.ceil(filesize_dl/1000.)), int(math.ceil(filesize/1000.)), int(math.ceil(filesize_dl*100.)/filesize))
-                     status += chr(8)*(len(status)+1)
--                    print status,
-+                    sys.stdout.write(status)
-         if print_progress:
--            print
-+            print('')
-         return (filesize, filesize_dl)
- 
-     def check_directories(self, dirs, print_progress=False):
-@@ -105,23 +100,23 @@ class uhd_images_downloader():
- 
-         def _check_part(head, tail=None):
-             if print_progress:
--                print "Checking: %s" % (head)
-+                print("Checking: %s" % (head))
-             if tail is not None and tail == "":
-                 return True
-             if not os.path.exists(head):
-                 if print_progress:
--                    print "Does not exist: %s" % (head)
-+                    print("Does not exist: %s" % (head))
-                 return _check_part(*os.path.split(head))
-             if not os.path.isdir(head):
-                 if print_progress:
--                    print "Is not a directory: %s" % (head)
-+                    print("Is not a directory: %s" % (head))
-                 return (False, head)
-             if not os.access(head, os.W_OK):
-                 if print_progress:
--                    print "Write permission denied on: %s" % (head)
-+                    print("Write permission denied on: %s" % (head))
-                 return (False, head)
-             if print_progress:
--                print "Write permission granted on: %s" % (head)
-+                print("Write permission granted on: %s" % (head))
-             return (True, head)
- 
-         return _check_part(dirs)
-@@ -137,34 +132,34 @@ class uhd_images_downloader():
-     def extract_images_archive(self, archive_path, destination=None, print_progress=False):
-         if not os.path.exists(archive_path):
-             if print_progress:
--                print "Path does not exist: %s" % (archive_path)
-+                print("Path does not exist: %s" % (archive_path))
-             raise Exception("path does not exist: %s" % (archive_path))
-         if print_progress:
--            print "Archive path: %s" % (archive_path)
-+            print("Archive path: %s" % (archive_path))
-         (head, tail) = os.path.split(archive_path)
- 
-         if not os.access(head, os.W_OK):
-             if print_progress:
--                print "Write access denied on: %s" % (head)
-+                print("Write access denied on: %s" % (head))
-             raise Exception("write access denied on: %s" % (head))
- 
-         (root, ext) = os.path.splitext(tail)
-         temp_dir = os.path.join(head, root)
- 
-         if print_progress:
--            print "Temporary extraction location: %s" % (temp_dir)
-+            print("Temporary extraction location: %s" % (temp_dir))
- 
-         if os.path.exists(temp_dir):
-             if print_progress:
--                print "Deleting existing location: %s" % (temp_dir)
-+                print("Deleting existing location: %s" % (temp_dir))
-             shutil.rmtree(temp_dir)
- 
-         if print_progress:
--            print "Creating directory: %s" % (temp_dir)
-+            print("Creating directory: %s" % (temp_dir))
-         os.mkdir(temp_dir)
- 
-         if print_progress:
--            print "Extracting archive %s to %s" % (archive_path, temp_dir)
-+            print("Extracting archive %s to %s" % (archive_path, temp_dir))
- 
-         images_zip = zipfile.ZipFile(archive_path)
-         images_zip.extractall(temp_dir)
-@@ -175,27 +170,27 @@ class uhd_images_downloader():
-     def install_images(self, source, dest, keep=False, print_progress=False):
-         if not os.path.exists(source):
-             if print_progress:
--                print "Source path does not exist: %s" % (source)
-+                print("Source path does not exist: %s" % (source))
-             return
- 
-         if keep:
-             if print_progress:
--                print "Not wiping directory tree (existing files will be overwritten): %s" % (dest)
-+                print("Not wiping directory tree (existing files will be overwritten): %s" % (dest))
-         elif os.path.exists(dest):
-             if print_progress:
--                print "Deleting directory tree: %s" % (dest)
-+                print("Deleting directory tree: %s" % (dest))
-             shutil.rmtree(dest)
- 
-         (head, tail) = os.path.split(source)
- 
-         if print_progress:
--            print "Source install path: %s" % (source)
-+            print("Source install path: %s" % (source))
- 
-         uhd_source = os.path.join(source, tail, *_BASE_DIR_STRUCTURE_PARTS)
- 
-         if print_progress:
--            print "Copying files from: %s" % (uhd_source)
--            print "Copying files to:   %s" % (dest)
-+            print("Copying files from: %s" % (uhd_source))
-+            print("Copying files to:   %s" % (dest))
- 
-         if keep:
-             # mgrant @ http://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all
-@@ -222,12 +217,12 @@ def main():
-     ### Set defaults from env variables
-     if os.environ.get("UHD_IMAGES_DIR") != None and os.environ.get("UHD_IMAGES_DIR") != "":
-         default_images_dir = os.environ.get("UHD_IMAGES_DIR")
--        print "UHD_IMAGES_DIR environment variable is set.\nDefault install location: {0}".format(default_images_dir)
-+        print("UHD_IMAGES_DIR environment variable is set.\nDefault install location: {0}".format(default_images_dir))
-     else:
-         default_images_dir = _DEFAULT_INSTALL_PATH
-     if os.environ.get("UHD_IMAGES_BASE_URL") != None and os.environ.get("UHD_IMAGES_BASE_URL") != "":
-         default_base_url = os.environ.get("UHD_IMAGES_BASE_URL")
--        print "UHD_IMAGES_BASE_URL environment variable is set.\nDefault base URL: {0}".format(default_base_url)
-+        print("UHD_IMAGES_BASE_URL environment variable is set.\nDefault base URL: {0}".format(default_base_url))
-     else:
-         default_base_url = _DEFAULT_BASE_URL
- 
-@@ -244,22 +239,22 @@ def main():
-     parser.add_option("-c", "--checksum",           type="string",          default=_AUTOGEN_IMAGES_CHECKSUM,
-                         help="Validate images archive against this checksum (blank to skip) [default=%default]")
-     parser.add_option("-t", "--checksum-type",      type="string",          default=_IMAGES_CHECKSUM_TYPE,
--                        help=("Select checksum hash function (options: %s) [default=%%default]" % (",".join(_checksum_fns.keys()))))
-+                        help=("Select checksum hash function (options: %s) [default=%%default]" % (",".join(list(_checksum_fns.keys())))))
-     parser.add_option("-k", "--keep",               action="store_true",    default=False,
-                         help="Do not clear images directory before extracting new files [default=%default]")
-     parser.add_option("-v", "--verbose",            action="store_true",    default=False,
-                         help="Enable verbose output [default=%default]")
-     (options, args) = parser.parse_args()
-     if options.buffer_size <= 0:
--        print "Invalid buffer size: %s" % (options.buffer_size)
-+        print("Invalid buffer size: %s" % (options.buffer_size))
-         return 1
- 
-     ### Select checksum algorithm (MD5)
-     checksum_fn = None
-     if options.checksum != "":
-         options.checksum_type = options.checksum_type.lower()
--        if not _checksum_fns.has_key(options.checksum_type):
--            print "Not a supported checksum function: %s" % (options.checksum_type)
-+        if options.checksum_type not in _checksum_fns:
-+            print("Not a supported checksum function: %s" % (options.checksum_type))
-             return 1
-         checksum_fn = _checksum_fns[options.checksum_type]
- 
-@@ -275,30 +270,30 @@ def main():
-         base_url_is_local = True
- 
-     if options.verbose:
--        print "Requested install location: %s" % (options.install_location)
--        print "Images base URL:            %s" % (options.base_url)
--        print "Images filename:            %s" % (options.filename)
--        print "Images checksum:            %s (%s)" % (options.checksum, _IMAGES_CHECKSUM_TYPE)
--        print "Final install location:     %s" % (images_dir)
--        print "Copying locally:            {0}".format("Yes" if base_url_is_local else "No")
-+        print("Requested install location: %s" % (options.install_location))
-+        print("Images base URL:            %s" % (options.base_url))
-+        print("Images filename:            %s" % (options.filename))
-+        print("Images checksum:            %s (%s)" % (options.checksum, _IMAGES_CHECKSUM_TYPE))
-+        print("Final install location:     %s" % (images_dir))
-+        print("Copying locally:            {0}".format("Yes" if base_url_is_local else "No"))
-     else:
--        print "Images destination:      %s" % (images_dir)
-+        print("Images destination:      %s" % (images_dir))
- 
-     ### Download or copy
-     downloader = uhd_images_downloader()
-     try:
-         (access, last_path) = downloader.check_directories(images_dir, print_progress=options.verbose)
-         if not access:
--            print "You do not have sufficient permissions to write to: %s" % (last_path)
--            print "Are you root?"
-+            print("You do not have sufficient permissions to write to: %s" % (last_path))
-+            print("Are you root?")
-             return 1
-         with temporary_directory() as temp_dir:
-             if options.verbose:
--                print "Using temporary directory: %s" % (temp_dir)
-+                print("Using temporary directory: %s" % (temp_dir))
-             temp_images_dest = os.path.join(temp_dir, options.filename)
-             if not base_url_is_local:
--                print "Downloading images from: {0}".format(images_url)
--                print "Downloading images to:   {0}".format(temp_images_dest)
-+                print("Downloading images from: {0}".format(images_url))
-+                print("Downloading images to:   {0}".format(temp_images_dest))
-                 (reported_size, downloaded_size) = downloader.download(
-                         images_url=images_url,
-                         filename=temp_images_dest,
-@@ -306,12 +301,12 @@ def main():
-                         print_progress=True
-                 )
-                 if options.verbose:
--                    print "Downloaded %d of %d bytes" % (downloaded_size, reported_size)
-+                    print("Downloaded %d of %d bytes" % (downloaded_size, reported_size))
-             else:
-                 local_images_pkg = os.path.join(options.base_url, options.filename)
--                print "Copying images from:     {0}".format(local_images_pkg)
-+                print("Copying images from:     {0}".format(local_images_pkg))
-                 if not os.path.isfile(local_images_pkg):
--                    print "[ERROR] No such file."
-+                    print("[ERROR] No such file.")
-                     return 1
-                 shutil.copyfile(local_images_pkg, temp_images_dest)
-             (checksum_match, calculated_checksum) = downloader.validate_checksum(
-@@ -321,48 +316,46 @@ def main():
-                     print_progress=options.verbose
-             )
-             if options.verbose:
--                print "Calculated checksum: %s" % (calculated_checksum)
-+                print("Calculated checksum: %s" % (calculated_checksum))
-             if checksum_match:
-                 if options.verbose:
-                     if options.checksum == "":
--                        print "Ignoring checksum"
-+                        print("Ignoring checksum")
-                     else:
--                        print "Checksum OK"
-+                        print("Checksum OK")
-                 try:
-                     extract_path = downloader.extract_images_archive(temp_images_dest, print_progress=options.verbose)
-                     if options.verbose:
--                        print "Image archive extracted to: %s" % (extract_path)
-+                        print("Image archive extracted to: %s" % (extract_path))
-                     downloader.install_images(extract_path, images_dir, options.keep, print_progress=options.verbose)
-                     if options.verbose:
--                        print "Cleaning up temp location: %s" % (extract_path)
-+                        print("Cleaning up temp location: %s" % (extract_path))
-                     shutil.rmtree(extract_path)
--                    print
--                    print "Images successfully installed to: %s" % (images_dir)
--                except Exception, e:
--                    print "Failed to install image archive: %s" % (e)
--                    print "This is usually a permissions problem."
--                    print "Please check your file system access rights and try again."
-+                    print("\nImages successfully installed to: %s" % (images_dir))
-+                except Exception as e:
-+                    print("Failed to install image archive: %s" % (e))
-+                    print("This is usually a permissions problem.")
-+                    print("Please check your file system access rights and try again.")
-                     if options.verbose:
-                         traceback.print_exc()
-                     else:
--                        print "You can run this again with the '--verbose' flag to see more information"
--                    print "If the problem persists, please email the output to: %s" % (_CONTACT)
-+                        print("You can run this again with the '--verbose' flag to see more information")
-+                    print("If the problem persists, please email the output to: %s" % (_CONTACT))
-             else:
--                print "Checksum of downloaded file is not correct (not installing - see options to override)"
--                print "Expected:   %s" % (options.checksum)
--                print "Calculated: %s" % (calculated_checksum)
--                print "Please try downloading again."
--                print "If the problem persists, please email the output to: %s" % (_CONTACT)
-+                print("Checksum of downloaded file is not correct (not installing - see options to override)")
-+                print("Expected:   %s" % (options.checksum))
-+                print("Calculated: %s" % (calculated_checksum))
-+                print("Please try downloading again.")
-+                print("If the problem persists, please email the output to: %s" % (_CONTACT))
-     except KeyboardInterrupt:
--        print
--        print "Cancelled at user request"
--    except Exception, e:
--        print "Downloader raised an unhandled exception: %s" % (e)
-+        print("\nCancelled at user request")
-+    except Exception as e:
-+        print("Downloader raised an unhandled exception: %s" % (e))
-         if options.verbose:
-             traceback.print_exc()
-         else:
--            print "You can run this again with the '--verbose' flag to see more information"
--        print "If the problem persists, please email the output to: %s" % (_CONTACT)
-+            print("You can run this again with the '--verbose' flag to see more information")
-+        print("If the problem persists, please email the output to: %s" % (_CONTACT))
-         return 1
-     return 0
- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150803/8cddb025/attachment-0001.html>


More information about the macports-changes mailing list