Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Adds Python 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno André Novo authored and DeeJayhX committed Apr 26, 2019
1 parent 690da22 commit 9f1d2aa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
5 changes: 3 additions & 2 deletions dwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import traceback
import webbrowser
from ctypes import windll
from six import u

import wx
from wx.lib.itemspicker import ItemsPicker, IP_SORT_SELECTED, IP_SORT_CHOICES, IP_REMOVE_FROM_CHOICES
Expand Down Expand Up @@ -470,10 +471,10 @@ def exception_hook(error, value, trace):
def check_elevated(silent=False):
if not bool(windll.advpack.IsNTAdmin(0, None)):
if silent:
windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), u"{0} -silent".format(unicode(__file__)), None, 1)
windll.shell32.ShellExecuteW(None, u"runas", u(sys.executable), u"{0} -silent".format(u(__file__)), None, 1)
sys.exit(1)
else:
windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)
windll.shell32.ShellExecuteW(None, u"runas", u(sys.executable), u(__file__), None, 1)
sys.exit(1)

def silent():
Expand Down
7 changes: 4 additions & 3 deletions dwt_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import datetime
import cgi
import json
import urllib2
from six.moves.urllib.request import urlopen
from six.moves.urllib.error import URLError
import webbrowser
from distutils.version import StrictVersion

Expand Down Expand Up @@ -169,8 +170,8 @@ def __init__(self, parent):

def update_check(parent):
try:
r = urllib2.urlopen('https://api.github.com/repos/10se1ucgo/DisableWinTracking/releases/latest')
except urllib2.URLError:
r = urlopen('https://api.github.com/repos/10se1ucgo/DisableWinTracking/releases/latest')
except URLError:
return
value, parameters = cgi.parse_header(r.headers.get('Content-Type', ''))
release = json.loads(r.read().decode(parameters.get('charset', 'utf-8')))
Expand Down
15 changes: 7 additions & 8 deletions dwt_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
from collections import OrderedDict
import pywintypes
import shutil
from string import split
import subprocess
import tempfile
import _winreg as winreg
from six.moves import winreg
import shlex

import win32serviceutil
Expand Down Expand Up @@ -66,12 +65,12 @@ def stdout(self, value):

def is_64bit():
if os.name == 'nt':
output = subprocess.check_output(['wmic', 'os', 'get', 'OSArchitecture'])
os_arch = output.split()[1]
return True if os_arch == '64-bit' else False
output = subprocess.check_output(['wmic', 'os', 'get', 'OSArchitecture'])
os_arch = output.split()[1]
return True if os_arch == '64-bit' else False
else:
logger.critical("This was only meant to be run on Windows-based system. Specifically, Windows 10.")
os._exit(0)
logger.critical("This was only meant to be run on Windows-based system. Specifically, Windows 10.")
os._exit(0)
return os_arch


Expand Down Expand Up @@ -101,7 +100,7 @@ def clear_diagtrack():
failed = False
for cmd in cmds:
i += 1
service = split(cmd, 'sc delete ')
service = cmd.split('sc delete ')


output = subprocess_handler(cmd)
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pypiwin32
six
wxpython

0 comments on commit 9f1d2aa

Please sign in to comment.