feross / SpoofMAC

:briefcase: Change your MAC address for debugging
https://feross.org/spoofmac/
3.02k stars 271 forks source link

Add Python 3 support #26

Closed asmeurer closed 9 years ago

asmeurer commented 10 years ago

Fixes #25.

I haven't tested this fully, so you should probably do a full run through to make sure everything works. I mainly ran 2to3, did a conditional import on winreg, and made the subprocess functions return strings instead of bytes with universal_newlines=True.

feross commented 10 years ago

@asmeurer Thanks for the PR!

@TkTech Are you free to take a look?

asmeurer commented 10 years ago

Thanks for the tool. I made the mistake of not downloading it soon enough at the Dallas airport (which has only 30 min. of free WiFi), but I got it on my other laptop and did this PR on the airplane. :airplane:

asmeurer commented 10 years ago

Or @otrebor

feross commented 10 years ago

@TkTech feel free to merge/publish whenever you're happy. I can give you permission to publish to PyPI since I haven't written Python in a while and I don't want to be the gatekeeper on this anymore.

feross commented 9 years ago

Superceded by #30

asmeurer commented 9 years ago

@feross can you please merge this pull request. The coding change is relevant, and the latest release of spoof mac fails for me

Traceback (most recent call last):
  File "/Users/aaronmeurer/anaconda/bin/spoof-mac.py", line 4, in <module>
    __import__('pkg_resources').run_script('SpoofMAC==2.0.0', 'spoof-mac.py')
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/pkg_resources.py", line 505, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/pkg_resources.py", line 1253, in run_script
    exec(script_code, namespace, namespace)
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/SpoofMAC-2.0.0-py3.4.egg/EGG-INFO/scripts/spoof-mac.py", line 136, in <module>
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/SpoofMAC-2.0.0-py3.4.egg/EGG-INFO/scripts/spoof-mac.py", line 82, in main
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/SpoofMAC-2.0.0-py3.4.egg/spoofmac/interface.py", line 444, in find_interface
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/SpoofMAC-2.0.0-py3.4.egg/spoofmac/interface.py", line 343, in find_interface
  File "/Users/aaronmeurer/anaconda/lib/python3.4/site-packages/SpoofMAC-2.0.0-py3.4.egg/spoofmac/interface.py", line 313, in find_interfaces
  File "/Users/aaronmeurer/anaconda/lib/python3.4/re.py", line 206, in findall
    return _compile(pattern, flags).findall(string)

(but it works in this branch)

feross commented 9 years ago

Can another maintainer comment on @asmeurer's comment?

pteek commented 9 years ago

I contributed the last changes to the master branch.

There is no difference in the current master and your PR except the universal_newlines option and my changes to windows wrapper and admin rights error message. I have not made any change to the MAC wrapper.

Only global change I made was renaming the script to spoof-mac.py because the .py is needed on windows and *nix can be fine with it being there.

Is there any other info about the fail? The trackback only tells so much.

I wonder why is this the only regex expression(line 309, interface.py) to be prefixed by "r"?

Also, I had problems with line endings where the script would just stop at some random point. Except this, I have no clue why your version works and mine doesn't on MAC.

feross commented 9 years ago

@pteek any reason to not use universal_newlines and change utf8 to utf-8?

pteek commented 9 years ago

@feross Looks good in my reading and testing(Linux and Windows).

I have added these changes to my master.

http://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation

This seems to be the ideal solution to the cross platform script installation problem. For now, I have duplicated the spoof-mac script(one without .py).

pteek commented 9 years ago

@asmeurer

https://github.com/pteek/SpoofMAC/commit/b64b6a8c2bca12e745043a35ddbd444ada349cbd#commitcomment-8750435

This is needed for python3. Your current python3 branch is broken because of this.

Are you currently testing with 2 or 3?

feross commented 9 years ago

@pteek You're a collaborator, so feel free to send a PR or merge your changes in directly (your call) and let me know when you want me to do a release. :)

pteek commented 9 years ago

Alright, thanks @feross.

On November 27, 2014 7:15:35 PM GMT+05:30, Feross Aboukhadijeh notifications@github.com wrote:

@pteek You're a collaborator, so feel free to send a PR or merge your changes in directly (your call) and let me know when you want me to do a release. :)


Reply to this email directly or view it on GitHub: https://github.com/feross/SpoofMAC/pull/26#issuecomment-64792012

Sent from my Android device with K-9 Mail. Please excuse my brevity.