ich habe nach einem anderem python geschrieben sourcecode den sourc ein mein source übernommen aber es kommt fheler beim kompilieren!
was ich über nommen habe sind diese codes:
Code: Alles auswählen
if (sys.platform == 'win32'):
self.icon = wxIcon('icon_bt.ico', wxBITMAP_TYPE_ICO)
self.starttime = time ()
self.frame = frame
if (sys.platform == 'win32'):
self.frame.SetIcon(self.icon)
Code: Alles auswählen
if (sys.platform == 'win32'):
EVT_ICONIZE(self.frame, self.onIconify)
Code: Alles auswählen
def onIconify(self, evt):
icon = 0
if self.config is None:
try:
self.config = self.dow.getConfig()
icon = self.config['win32_taskbar_icon']
except NameError:
icon = 1
else:
icon = self.config['win32_taskbar_icon']
if (icon):
if not hasattr(self.frame, "tbicon"):
self.frame.tbicon = wxTaskBarIcon()
self.frame.tbicon.SetIcon(self.icon, "BitTorrent")
# setup a taskbar icon, and catch some events from it
EVT_TASKBAR_LEFT_DCLICK(self.frame.tbicon, self.onTaskBarActivate)
EVT_TASKBAR_RIGHT_UP(self.frame.tbicon, self.onTaskBarMenu)
EVT_MENU(self.frame.tbicon, self.TBMENU_RESTORE, self.onTaskBarActivate)
EVT_MENU(self.frame.tbicon, self.TBMENU_CLOSE, self.done)
self.frame.Hide()
else:
self.frame.Iconize(1)
def onTaskBarActivate(self, evt):
if self.frame.IsIconized():
self.frame.Iconize(false)
if not self.frame.IsShown():
self.frame.Show(true)
self.frame.Raise()
if hasattr(self.frame, "tbicon"):
del self.frame.tbicon
return
TBMENU_RESTORE = 1000
TBMENU_CLOSE = 1001
def onTaskBarMenu(self, evt):
menu = wxMenu()
menu.Append(self.TBMENU_RESTORE, "Restore BitTorrent")
menu.Append(self.TBMENU_CLOSE, "Close")
self.frame.tbicon.PopupMenu(menu)
menu.Destroy()
Code: Alles auswählen
#!/usr/bin/env python
# Written by Bram Cohen and Myers Carpenter
# see LICENSE.txt for license information
from sys import argv
from BitTorrent import version
from BitTorrent.download import download
from btdownloadheadless import print_spew
from threading import Event, Thread
from os.path import join, split, exists
from os import getcwd
from wxPython.wx import *
from time import strftime, time
from webbrowser import open_new
from traceback import print_exc
import sys
def hours(n):
if n == -1:
return '<unknown>'
if n == 0:
return 'complete!'
n = int(n)
h, r = divmod(n, 60 * 60)
m, sec = divmod(r, 60)
if h > 1000000:
return '<unknown>'
if h > 0:
return '%d hour %02d min %02d sec' % (h, m, sec)
else:
return '%d min %02d sec' % (m, sec)
wxEVT_INVOKE = wxNewEventType()
def EVT_INVOKE(win, func):
win.Connect(-1, -1, wxEVT_INVOKE, func)
class InvokeEvent(wxPyEvent):
def __init__(self):
wxPyEvent.__init__(self)
self.SetEventType(wxEVT_INVOKE)
class DownloadInfoFrame:
def __init__(self, flag):
frame = wxFrame(None, -1, 'BitTorrent ' + version + ' download', size = wxSize(400, 250))
self.frame = frame
self.flag = flag
self.uiflag = Event()
self.fin = False
self.last_update_time = 0
self.showing_error = False
self.event = InvokeEvent()
self.funclist = []
if (sys.platform == 'win32'):
self.icon = wxIcon('bittorrent.ico', wxBITMAP_TYPE_ICO)
self.starttime = time ()
self.frame = frame
if (sys.platform == 'win32'):
self.frame.SetIcon(self.icon)
panel = wxPanel(frame, -1)
colSizer = wxFlexGridSizer(cols = 1, vgap = 3)
fnsizer = wxBoxSizer(wxHORIZONTAL)
self.fileNameText = wxStaticText(panel, -1, '', style = wxALIGN_LEFT)
fnsizer.Add(self.fileNameText, 1, wxALIGN_BOTTOM)
#I2P: cant have this for anonymity reasons
# self.aboutText = wxStaticText(panel, -1, 'about', style = wxALIGN_RIGHT)
# self.aboutText.SetForegroundColour('Blue')
# self.aboutText.SetFont(wxFont(14, wxNORMAL, wxNORMAL, wxNORMAL, True))
# fnsizer.Add(self.aboutText, 0, wxEXPAND)
#/I2P
colSizer.Add(fnsizer, 0, wxEXPAND)
self.gauge = wxGauge(panel, -1, range = 1000, style = wxGA_SMOOTH)
colSizer.Add(self.gauge, 0, wxEXPAND)
gridSizer = wxFlexGridSizer(cols = 2, vgap = 3, hgap = 8)
gridSizer.Add(wxStaticText(panel, -1, 'Estimated time left:'))
self.timeEstText = wxStaticText(panel, -1, '')
gridSizer.Add(self.timeEstText, 0, wxEXPAND)
gridSizer.Add(wxStaticText(panel, -1, 'Download to:'))
self.fileDestText = wxStaticText(panel, -1, '')
gridSizer.Add(self.fileDestText, 0, wxEXPAND)
gridSizer.AddGrowableCol(1)
rategridSizer = wxFlexGridSizer(cols = 4, vgap = 3, hgap = 8)
rategridSizer.Add(wxStaticText(panel, -1, 'Download rate:'))
self.downRateText = wxStaticText(panel, -1, '')
rategridSizer.Add(self.downRateText, 0, wxEXPAND)
rategridSizer.Add(wxStaticText(panel, -1, 'Downloaded:'))
self.downTotalText = wxStaticText(panel, -1, '')
rategridSizer.Add(self.downTotalText, 0, wxEXPAND)
rategridSizer.Add(wxStaticText(panel, -1, 'Upload rate:'))
self.upRateText = wxStaticText(panel, -1, '')
rategridSizer.Add(self.upRateText, 0, wxEXPAND)
rategridSizer.Add(wxStaticText(panel, -1, 'Uploaded:'))
self.upTotalText = wxStaticText(panel, -1, '')
rategridSizer.Add(self.upTotalText, 0, wxEXPAND)
rategridSizer.AddGrowableCol(1)
rategridSizer.AddGrowableCol(3)
colSizer.Add(gridSizer, 0, wxEXPAND)
colSizer.Add(rategridSizer, 0, wxEXPAND)
#I2P: wxPython 2.5 fix
colSizer.Add((50, 50), 0, wxEXPAND)
#/I2P
self.cancelButton = wxButton(panel, -1, 'Cancel')
colSizer.Add(self.cancelButton, 0, wxALIGN_CENTER)
colSizer.AddGrowableCol(0)
colSizer.AddGrowableRow(3)
border = wxBoxSizer(wxHORIZONTAL)
border.Add(colSizer, 1, wxEXPAND | wxALL, 4)
panel.SetSizer(border)
panel.SetAutoLayout(True)
#I2P: we cant have this for anonymity reasons
# EVT_LEFT_DOWN(self.aboutText, self.donate)
#/I2P
EVT_CLOSE(frame, self.done)
EVT_BUTTON(frame, self.cancelButton.GetId(), self.done)
EVT_INVOKE(frame, self.onInvoke)
if (sys.platform == 'win32'):
EVT_ICONIZE(self.frame, self.onIconify)
self.frame.SetIcon(wxIcon(join(split(argv[0])[0], 'bittorrent.ico'), wxBITMAP_TYPE_ICO))
self.frame.Show()
#I2P: we cant have this for anonymity reasons
# def donate(self, event):
# Thread(target = self.donate2).start()
#
# def donate2(self):
# open_new('http://bitconjurer.org/BitTorrent/donate.html')
#/I2P
def onIconify(self, evt):
icon = 0
if self.config is None:
try:
self.config = self.dow.getConfig()
icon = self.config['win32_taskbar_icon']
except NameError:
icon = 1
else:
icon = self.config['win32_taskbar_icon']
if (icon):
if not hasattr(self.frame, "tbicon"):
self.frame.tbicon = wxTaskBarIcon()
self.frame.tbicon.SetIcon(self.icon, "BitTorrent")
# setup a taskbar icon, and catch some events from it
EVT_TASKBAR_LEFT_DCLICK(self.frame.tbicon, self.onTaskBarActivate)
EVT_TASKBAR_RIGHT_UP(self.frame.tbicon, self.onTaskBarMenu)
EVT_MENU(self.frame.tbicon, self.TBMENU_RESTORE, self.onTaskBarActivate)
EVT_MENU(self.frame.tbicon, self.TBMENU_CLOSE, self.done)
self.frame.Hide()
else:
self.frame.Iconize(1)
def onTaskBarActivate(self, evt):
if self.frame.IsIconized():
self.frame.Iconize(false)
if not self.frame.IsShown():
self.frame.Show(true)
self.frame.Raise()
if hasattr(self.frame, "tbicon"):
del self.frame.tbicon
return
TBMENU_RESTORE = 1000
TBMENU_CLOSE = 1001
def onTaskBarMenu(self, evt):
menu = wxMenu()
menu.Append(self.TBMENU_RESTORE, "Restore BitTorrent")
menu.Append(self.TBMENU_CLOSE, "Close")
self.frame.tbicon.PopupMenu(menu)
menu.Destroy()
def onInvoke(self, event):
while not self.uiflag.isSet() and self.funclist:
func, args, kwargs = self.funclist.pop(0)
apply(func, args, kwargs)
def invokeLater(self, func, args = [], kwargs = {}):
if not self.uiflag.isSet():
self.funclist.append((func, args, kwargs))
if len(self.funclist) == 1:
wxPostEvent(self.frame, self.event)
def updateStatus(self, d):
if (self.last_update_time + 0.1 < time() and not self.showing_error) or d.get('fractionDone') in (0.0, 1.0) or d.has_key('activity'):
self.invokeLater(self.onUpdateStatus, [d])
def onUpdateStatus(self, d):
try:
if d.has_key('spew'):
print_spew(d['spew'])
activity = d.get('activity')
fractionDone = d.get('fractionDone')
timeEst = d.get('timeEst')
downRate = d.get('downRate')
upRate = d.get('upRate')
downTotal = d.get('downTotal')
upTotal = d.get('upTotal')
if activity is not None and not self.fin:
self.timeEstText.SetLabel(activity)
if fractionDone is not None and not self.fin:
self.gauge.SetValue(int(fractionDone * 1000))
self.frame.SetTitle('%d%% %s - BitTorrent %s' % (int(fractionDone*100), self.filename, version))
if timeEst is not None:
self.timeEstText.SetLabel(hours(timeEst))
if downRate is not None:
self.downRateText.SetLabel('%.0f KiB/s' % (float(downRate) / (1 << 10)))
if upRate is not None:
self.upRateText.SetLabel('%.0f KiB/s' % (float(upRate) / (1 << 10)))
if downTotal is not None:
self.downTotalText.SetLabel('%.1f M' % (downTotal))
if upTotal is not None:
self.upTotalText.SetLabel('%.1f M' % (upTotal))
self.last_update_time = time()
except:
print_exc()
def finished(self):
self.fin = True
self.invokeLater(self.onFinishEvent)
def failed(self):
self.fin = True
self.invokeLater(self.onFailEvent)
def error(self, errormsg):
if not self.showing_error:
self.invokeLater(self.onErrorEvent, [errormsg])
def onFinishEvent(self):
self.timeEstText.SetLabel('Download Succeeded!')
self.cancelButton.SetLabel('Close')
self.gauge.SetValue(1000)
self.frame.SetTitle('%s - Upload - BitTorrent %s' % (self.filename, version))
self.downRateText.SetLabel('')
def onFailEvent(self):
self.timeEstText.SetLabel('Failed!')
self.cancelButton.SetLabel('Close')
self.gauge.SetValue(0)
self.downRateText.SetLabel('')
def onErrorEvent(self, errormsg):
self.showing_error = True
dlg = wxMessageDialog(self.frame, message = errormsg,
caption = 'Download Error', style = wxOK | wxICON_ERROR)
dlg.Fit()
dlg.Center()
dlg.ShowModal()
self.showing_error = False
def chooseFile(self, default, size, saveas, dir):
f = Event()
bucket = [None]
self.invokeLater(self.onChooseFile, [default, bucket, f, size, dir, saveas])
f.wait()
return bucket[0]
def onChooseFile(self, default, bucket, f, size, dir, saveas):
if not saveas:
if dir:
dl = wxDirDialog(self.frame, 'Choose a directory to save to, pick a partial download to resume',
join(getcwd(), default), style = wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON)
else:
dl = wxFileDialog(self.frame, 'Choose file to save as, pick a partial download to resume', '', default, '*', wxSAVE)
if dl.ShowModal() != wxID_OK:
self.done(None)
f.set()
return
saveas = dl.GetPath()
bucket[0] = saveas
self.fileNameText.SetLabel('%s (%.1f MB)' % (default, float(size) / (1 << 20)))
self.timeEstText.SetLabel('Starting up...')
self.fileDestText.SetLabel(saveas)
self.filename = default
self.frame.SetTitle(default + '- BitTorrent ' + version)
f.set()
def newpath(self, path):
self.fileDestText.SetLabel(path)
def done(self, event):
self.uiflag.set()
self.flag.set()
self.frame.Destroy()
class btWxApp(wxApp):
def __init__(self, x, params):
self.params = params
wxApp.__init__(self, x)
def OnInit(self):
doneflag = Event()
#I2P: workaround for wxpython 2.4.x
wxInitAllImageHandlers()
#/I2P
d = DownloadInfoFrame(doneflag)
self.SetTopWindow(d.frame)
#I2P: no args => file dialog
if ''.join(self.params)[:2] in ['--','']:
b = wxFileDialog (d.frame, 'Choose .torrent file to use',
defaultDir = '', defaultFile = '', wildcard = '*.torrent',
style = wxOPEN)
if b.ShowModal() == wxID_OK:
self.params.insert(0, b.GetPath())
else:
d.done(None)
return 1
#/I2P
thread = Thread(target = next, args = [self.params, d, doneflag])
thread.setDaemon(False)
thread.start()
return 1
def run(params):
try:
app = btWxApp(0, params)
app.MainLoop()
except:
print_exc()
def next(params, d, doneflag):
try:
#I2P: remove donation shit, anonymity reasons
# p = join(split(argv[0])[0], 'donated')
# if not exists(p) and long(time()) % 3 == 0:
# open_new('http://bitconjurer.org/BitTorrent/donate.html')
# dlg = wxMessageDialog(d.frame, 'BitTorrent is Donation supported software. ' +
# 'Please go to the donation page (which should be appearing for you now) and make a donation from there. ' +
# 'Or you can click no and donate later.\n\nHave you made a donation yet?',
# 'Donate!', wxYES_NO | wxICON_INFORMATION | wxNO_DEFAULT)
# if dlg.ShowModal() == wxID_YES:
# dlg.Destroy()
# dlg = wxMessageDialog(d.frame, 'Thanks for your donation! You will no longer be shown donation requests.\n\n' +
# "If you haven't actually made a donation and are feeling guilty (as you should!) you can always get to " +
# "the donation page by clicking the 'about' link in the upper-right corner of the main BitTorrent window and " +
# 'donating from there.', 'Thanks!', wxOK)
# dlg.ShowModal()
# dlg.Destroy()
# try:
# open(p, 'wb').close()
# except IOError, e:
# dlg = wxMessageDialog(d.frame, "Sorry, but I couldn't set the flag to not ask you for donations in the future - " + str(e),
# 'Sorry!', wxOK | wxICON_ERROR)
# dlg.ShowModal()
# dlg.Destroy()
# else:
# dlg.Destroy()
#/I2P
download(params, d.chooseFile, d.updateStatus, d.finished, d.error, doneflag, 100, d.newpath)
if not d.fin:
d.failed()
except:
print_exc()
if __name__ == '__main__':
run(argv[1:])
(C) Copyright 1985-2001 Microsoft Corp.
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p
-bt\build.bat
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>del /F /S /Q build dist
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>c:\python23\python.exe winsetup.py py2
exe
running py2exe
*** searching for required modules ***
error: compiling 'btdownloadgui.py' failed
IndentationError: unindent does not match any outer indentation level (btdow
nloadgui.py, line 149)
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>e:\Programme\NSIS\makensis.exe" bittor
rent.nsi
Der Befehl "e:\Programme\NSIS\makensis.exe" bittorrent.nsi" ist entweder falsch
geschrieben oder
konnte nicht gefunden werden.
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p
-bt\build.bat
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>del /F /S /Q build dist
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>c:\python23\python.exe winsetup.py py2
exe
running py2exe
*** searching for required modules ***
error: compiling 'btdownloadgui.py' failed
IndentationError: unindent does not match any outer indentation level (btdow
nloadgui.py, line 148)
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>e:\Programme\NSIS\makensis.exe" bittor
rent.nsi
Der Befehl "e:\Programme\NSIS\makensis.exe" bittorrent.nsi" ist entweder falsch
geschrieben oder
konnte nicht gefunden werden.
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p
-bt\build.bat
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>del /F /S /Q build dist
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>c:\python23\python.exe winsetup.py py2
exe
running py2exe
*** searching for required modules ***
error: compiling 'btdownloadgui.py' failed
IndentationError: unindent does not match any outer indentation level (btdow
nloadgui.py, line 150)
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>e:\Programme\NSIS\makensis.exe" bittor
rent.nsi
Der Befehl "e:\Programme\NSIS\makensis.exe" bittorrent.nsi" ist entweder falsch
geschrieben oder
konnte nicht gefunden werden.
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p
-bt\build.bat
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>del /F /S /Q build dist
E:\Bittorrent-I2P\BitTorrent-3.4.2\i2p-bt>c:\python23\python.exe winsetup.py py2
exe
running py2exe
*** searching for required modules ***
error: compiling 'btdownloadgui.py' failed
IndentationError: unindent does not match any outer indentation level (btdow
nloadgui.py, line 151)
das ist der fehler im cmd:
kann mit jemand weiterhelfen?E:\Bittest\i2p\build.bat
E:\Bittest\i2p-bt>del /F /S /Q build dist
E:\Bitest\i2p-bt>c:\python23\python.exe winsetup.py py2
exe
running py2exe
*** searching for required modules ***
error: compiling 'btdownloadgui.py' failed
IndentationError: unindent does not match any outer indentation level (btdownloadgui.py, line 151)
mfg
matrixnet