Skip to content

Commit 4826093

Browse files
committed
Simplify dependencies: remove requirement for pip and pyusb
1 parent ee7b85f commit 4826093

18 files changed

+5861
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
This tool should be compatible with Mac and Linux. It won't work in a virtual machine.
2626

27-
* [pip](https://pip.pypa.io/en/stable/installing/)
2827
* libusb, `brew install libusb`
29-
* pyusb, `pip install pyusb`
3028
* [iPhone 3GS iOS 4.3.5 iBSS](#ibss)
3129
* [libusb patch for El Capitan and Sierra](#patch)
3230

@@ -115,3 +113,5 @@ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
115113
## Credit
116114

117115
geohot for limera1n exploit
116+
117+
walac for pyusb

usb/ACKNOWLEDGEMENTS

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Alan Aguiar
2+
jaseg
3+
Johannes Stezenbach
4+
Marijn van Vliet
5+
Stefano Di Martino
6+
Simon Norberg
7+
iThompson
8+
Harry Bock
9+
ponty
10+
Chris Clark
11+
themperek
12+
David Halter
13+
Robert von Burg
14+
James Rowe
15+
Braiden Kindt
16+
Tormod Volden
17+
Chris Clark
18+
Emmanuel Blot
19+
Peter Bigot
20+
Travis Robinson
21+
Xiaofan Chen
22+
Poul-Henning Kamp
23+
Thomas Reitmayr
24+
Carl Ritson
25+
Romain Aviolat
26+
Walker Inman
27+
Prathmesh Prabhu
28+
André Erdmann
29+
Jeffrey Nichols
30+
Deliang Fan
31+
Matthew Chan
32+
Maximilian Köhl

usb/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (C) 2009-2014 Wander Lairson Costa. All Rights Reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions
5+
are met:
6+
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
14+
3. The name of the author may not be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
18+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20+
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26+
OF SUCH DAMAGE.
27+

usb/README.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
=======================================
2+
PyUSB 1.0 - Easy USB access from Python
3+
=======================================
4+
5+
Introduction
6+
============
7+
8+
The PyUSB module provides for Python easy access to the host
9+
machine's Universal Serial Bus (USB) system.
10+
11+
Until 0.4 version, PyUSB used to be a thin wrapper over libusb.
12+
With 1.0 version, things changed considerably. Now PyUSB is an
13+
API rich, backend neutral Python USB module easy to use.
14+
15+
As with most Python modules, PyUSB's documentation is based on Python
16+
doc strings and can therefore be manipulated by tools such as pydoc.
17+
18+
You can also find a tutorial at:
19+
https://github.com/walac/pyusb/blob/master/docs/tutorial.rst.
20+
21+
PyUSB is being developed and tested on Linux and Windows, but it should work
22+
fine on any platform running Python >= 2.4, ctypes and at least one of the
23+
builtin backends.
24+
25+
PyUSB supports libusb 0.1, libusb 1.0 and OpenUSB, but the user does not need
26+
to worry about that, unless in some corner cases.
27+
28+
If you have any question about PyUSB, you can use the PyUSB mailing list
29+
hosted in the SourceForge. In the PyUSB website (http://walac.github.io/pyusb)
30+
you can find instructions on how to subscribe to the mailing list.
31+
32+
Installing PyUSB on GNU/Linux Systems
33+
=====================================
34+
35+
These instructions are for Debian-based systems. Instructions for
36+
other flavors of GNU/Linux should be similar.
37+
38+
You will first need to install the following packages:
39+
40+
1) python (PyUSB is useless without it), version >= 2.4
41+
2) At least one of the supported libraries (libusb 1.0, libusb 0.1 or OpenUSB)
42+
3) If your Python version is < 2.5, you have to install ctypes as a separate
43+
package, because these versions of Python does not ship it.
44+
45+
For example, the command::
46+
47+
$ sudo apt-get install python libusb-1.0-0
48+
49+
should install all these packages on most Debian-based systems with
50+
access to the proper package repositories.
51+
52+
Once the above packages are installed, you can install PyUSB
53+
with the command::
54+
55+
$ sudo python setup.py install
56+
57+
Run it as root from within the same directory as this README file.
58+
59+
You can also use `pip <https://docs.python.org/3/installing/>`_ to
60+
install PyUSB::
61+
62+
$ sudo pip install pyusb --pre
63+
64+
Just bear in mind that you still follow to procedure to install the
65+
libusb library.
66+
67+
For pure Debian variants
68+
------------------------
69+
70+
For pure Debian systems you are advised to install either the
71+
python-usb or python3-usb packages. These are prebuilt based on
72+
PyUSB and libusb-1.0::
73+
74+
$ sudo apt-get install python-usb python3-usb
75+
76+
You may wish to get the backported version 1.0, since PyUSB
77+
doesn't depend upon any truly unstable packages.
78+
79+
Installing PyUSB on Windows
80+
===========================
81+
82+
Now that PyUSB is 100% written in Python, you install it on Windows
83+
in the same way you do on Linux::
84+
85+
python setup.py install
86+
87+
If you get some kind of "command not found" error, make sure to add
88+
the Python install directory to your PATH environment variable or
89+
give the complete path to the Python interpreter.
90+
91+
Remember that you need libusb (1.0 or 0.1) or OpenUSB running on your
92+
system. For Windows users, libusb 0.1 is provided through
93+
`libusb-win32 <http://libusb-win32.sourceforge.net>`_
94+
package. Check the libusb website for updates
95+
(http://www.libusb.info).
96+
97+
Reporting bugs/Submitting patches
98+
=================================
99+
100+
Some people have been sending patches and reporting bugs directly
101+
at my email. Please, do it through
102+
`github <https://github.com/walac/pyusb>`_, I had a hardtime tracking
103+
their names to put them in the acknowledgments file. ;-)
104+
105+
PS: this README file was based on the great Josh Lifton's one... ^_^

usb/__init__.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright (C) 2009-2014 Wander Lairson Costa
2+
#
3+
# The following terms apply to all files associated
4+
# with the software unless explicitly disclaimed in individual files.
5+
#
6+
# The authors hereby grant permission to use, copy, modify, distribute,
7+
# and license this software and its documentation for any purpose, provided
8+
# that existing copyright notices are retained in all copies and that this
9+
# notice is included verbatim in any distributions. No written agreement,
10+
# license, or royalty fee is required for any of the authorized uses.
11+
# Modifications to this software may be copyrighted by their authors
12+
# and need not follow the licensing terms described here, provided that
13+
# the new terms are clearly indicated on the first page of each file where
14+
# they apply.
15+
#
16+
# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
17+
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
18+
# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
19+
# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
20+
# POSSIBILITY OF SUCH DAMAGE.
21+
#
22+
# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
23+
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
24+
# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
25+
# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
26+
# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
27+
# MODIFICATIONS.
28+
29+
r"""PyUSB - Easy USB access in Python
30+
31+
This package exports the following modules and subpackages:
32+
33+
core - the main USB implementation
34+
legacy - the compatibility layer with 0.x version
35+
backend - the support for backend implementations.
36+
control - USB standard control requests.
37+
libloader - helper module for backend library loading.
38+
39+
Since version 1.0, main PyUSB implementation lives in the 'usb.core'
40+
module. New applications are encouraged to use it.
41+
"""
42+
43+
import logging
44+
import os
45+
46+
__author__ = 'Wander Lairson Costa'
47+
48+
# Use Semantic Versioning, http://semver.org/
49+
version_info = (1, 0, 0)
50+
__version__ = '%d.%d.%d' % version_info
51+
52+
__all__ = ['legacy', 'control', 'core', 'backend', 'util', 'libloader']
53+
54+
def _setup_log():
55+
from usb import _debug
56+
logger = logging.getLogger('usb')
57+
debug_level = os.getenv('PYUSB_DEBUG')
58+
59+
if debug_level is not None:
60+
_debug.enable_tracing(True)
61+
filename = os.getenv('PYUSB_LOG_FILENAME')
62+
63+
LEVELS = {'debug': logging.DEBUG,
64+
'info': logging.INFO,
65+
'warning': logging.WARNING,
66+
'error': logging.ERROR,
67+
'critical': logging.CRITICAL}
68+
69+
level = LEVELS.get(debug_level, logging.CRITICAL + 10)
70+
logger.setLevel(level = level)
71+
72+
try:
73+
handler = logging.FileHandler(filename)
74+
except:
75+
handler = logging.StreamHandler()
76+
77+
fmt = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')
78+
handler.setFormatter(fmt)
79+
logger.addHandler(handler)
80+
else:
81+
class NullHandler(logging.Handler):
82+
def emit(self, record):
83+
pass
84+
85+
# We set the log level to avoid delegation to the
86+
# parent log handler (if there is one).
87+
# Thanks to Chris Clark to pointing this out.
88+
logger.setLevel(logging.CRITICAL + 10)
89+
90+
logger.addHandler(NullHandler())
91+
92+
93+
_setup_log()
94+
95+
# We import all 'legacy' module symbols to provide compatibility
96+
# with applications that use 0.x versions.
97+
from usb.legacy import *

usb/_debug.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright (C) 2009-2014 Wander Lairson Costa
2+
#
3+
# The following terms apply to all files associated
4+
# with the software unless explicitly disclaimed in individual files.
5+
#
6+
# The authors hereby grant permission to use, copy, modify, distribute,
7+
# and license this software and its documentation for any purpose, provided
8+
# that existing copyright notices are retained in all copies and that this
9+
# notice is included verbatim in any distributions. No written agreement,
10+
# license, or royalty fee is required for any of the authorized uses.
11+
# Modifications to this software may be copyrighted by their authors
12+
# and need not follow the licensing terms described here, provided that
13+
# the new terms are clearly indicated on the first page of each file where
14+
# they apply.
15+
#
16+
# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
17+
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
18+
# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
19+
# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
20+
# POSSIBILITY OF SUCH DAMAGE.
21+
#
22+
# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
23+
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
24+
# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
25+
# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
26+
# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
27+
# MODIFICATIONS.
28+
29+
__author__ = 'Wander Lairson Costa'
30+
31+
__all__ = ['methodtrace', 'functiontrace']
32+
33+
import logging
34+
import usb._interop as _interop
35+
36+
_enable_tracing = False
37+
38+
def enable_tracing(enable):
39+
global _enable_tracing
40+
_enable_tracing = enable
41+
42+
def _trace_function_call(logger, fname, *args, **named_args):
43+
logger.debug(
44+
# TODO: check if 'f' is a method or a free function
45+
fname + '(' + \
46+
', '.join((str(val) for val in args)) + \
47+
', '.join((name + '=' + str(val) for name, val in named_args.items())) + ')'
48+
)
49+
50+
# decorator for methods calls tracing
51+
def methodtrace(logger):
52+
def decorator_logging(f):
53+
if not _enable_tracing:
54+
return f
55+
def do_trace(*args, **named_args):
56+
# this if is just a optimization to avoid unecessary string formatting
57+
if logging.DEBUG >= logger.getEffectiveLevel():
58+
fn = type(args[0]).__name__ + '.' + f.__name__
59+
_trace_function_call(logger, fn, *args[1:], **named_args)
60+
return f(*args, **named_args)
61+
_interop._update_wrapper(do_trace, f)
62+
return do_trace
63+
return decorator_logging
64+
65+
# decorator for methods calls tracing
66+
def functiontrace(logger):
67+
def decorator_logging(f):
68+
if not _enable_tracing:
69+
return f
70+
def do_trace(*args, **named_args):
71+
# this if is just a optimization to avoid unecessary string formatting
72+
if logging.DEBUG >= logger.getEffectiveLevel():
73+
_trace_function_call(logger, f.__name__, *args, **named_args)
74+
return f(*args, **named_args)
75+
_interop._update_wrapper(do_trace, f)
76+
return do_trace
77+
return decorator_logging

0 commit comments

Comments
 (0)