我试图用kivy制作应用程序,但我的许可被拒绝了。我通过添加ppa和使用sudo apt-get在kivy网站上为xubuntu安装了推荐的方法。当我运行应用程序时,GUI会出现但是当我按下一个应该返回一些文本的按钮时,gui会关闭并且我收到一个错误,我的班级' MITMs1'没有属性' self'。我也在使用scapy和我在python 2.7上。
这是一个类似的问题https://i11.at/dwl/eos/kivy30.pdf,但我的错误是
OSError: [Errno 13] Permission denied: '/dev/input/event5'
我的完整输出是
[INFO ] [Logger ] Record log in /home/ro/.kivy/logs/kivy_15-12-27_25.txt
[INFO ] [Kivy ] v1.9.0
[INFO ] [Python ] v2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2]
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Factory ] 173 symbols loaded
[INFO ] [Text ] Provider: sdl2
WARNING: No route found for IPv6 destination :: (no default route?)
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] OpenGL version <3.0 Mesa 10.3.2>
[INFO ] [GL ] OpenGL vendor <Intel Open Source Technology Center>
[INFO ] [GL ] OpenGL renderer <Mesa DRI Intel(R) Bay Trail >
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Shading version <1.30>
[INFO ] [GL ] Texture max size <8192>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [GL ] NPOT texture support is available
[INFO ] [ProbeSysfs ] device match: /dev/input/event5
[INFO ] [MTD ] Read event from </dev/input/event5>
[INFO ] [Base ] Start application main loop
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/input/providers/mtdev.py", line 197, in _thread_run
_device = Device(_fn)
File "/usr/lib/python2.7/dist-packages/kivy/lib/mtdev.py", line 131, in __init__
self._fd = os.open(filename, os.O_NONBLOCK | os.O_RDONLY)
OSError: [Errno 13] Permission denied: '/dev/input/event5'
[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "skivy.py", line 76, in <module>
MITMtool().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 824, in run
runTouchApp()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 487, in runTouchApp
EventLoop.window.mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 539, in mainloop
self._mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 300, in _mainloop
EventLoop.idle()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 330, in idle
self.dispatch_input()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 315, in dispatch_input
post_dispatch_input(*pop(0))
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 281, in post_dispatch_input
wid.dispatch('on_touch_up', me)
File "_event.pyx", line 699, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:6856)
File "/usr/lib/python2.7/dist-packages/kivy/uix/behaviors.py", line 163, in on_touch_up
self.dispatch('on_release')
File "_event.pyx", line 695, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:6815)
File "_event.pyx", line 1168, in kivy._event.EventObservers.dispatch (kivy/_event.c:11690)
File "_event.pyx", line 1052, in kivy._event.EventObservers._dispatch (kivy/_event.c:10730)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1465, in custom_callback
exec(__kvlang__.co_value, idmap)
File "<string>", line 23, in <module>
File "skivy.py", line 64, in run_ifconfig
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.ipv6) + '\n\n'
AttributeError: 'MITMs1' object has no attribute 'self'
我的代码是
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.lang import Builder
from kivy.app import App
from scapy.all import *
from kivy.uix.scrollview import ScrollView
from kivy.uix.screenmanager import ScreenManager, Screen
from subprocess import check_output
Builder.load_string('''
<MITMs1>:
BoxLayout:
BoxLayout:
orientation: 'vertical'
id: client_box
size_hint: 0.5, 1
spacing: 10
Label:
id: device_lbl
markup: True
size_hint: 1, 1
text: 'LABEL! :)'
TextInput:
id: iface_name
size_hint: 1, .2
text: 'eth0'
multiline: False
BoxLayout:
Button:
size_hint: 1, .2
text: 'Run Ifconfig'
on_release: root.run_ifconfig()
ScrollView:
size_hint: 0.5, 1
do_scroll_x: False
BoxLayout:
orientation: 'vertical'
id: nodes
size_hint: 1, None
''')
class MITMs1(Screen):
def __init__(self, **kwargs):
super(MITMs1, self).__init__(**kwargs)
self.iface_name = self.ids['iface_name']
self.device_lbl = self.ids['device_lbl']
self.client_box = self.ids['client_box']
self.nodes = self.ids['nodes']
def run_ifconfig(self):
self.ifconfig = subprocess.check_output(['ifconfig', self.iface_name.text])
self.iface, self.my_ip, self.MAC, self.Bcast, self.Nmask, self.ipv6 = (self.ifconfig.split()[i] for i in (0, 6, 4, 7, 8, 11))
self.device_lbl.text = ('[color=00ff00][i][b]My Device[/b][/i][/color]' + '\n\n' + 'Interface: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.iface) + '\n\n' + 'IP: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.my_ip[5:]) + '\n\n' + 'MAC: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.self.MAC) + '\n\n' + 'Bcast: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.Bcast[6:]) + '\n\n' + 'Nmask: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.Nmask[5:]) + '\n\n' + 'IP: '
+ '[color=00ff00][i]{0}[/i][/color]'.format(self.ipv6) + '\n\n'
)
class MITMtool(App):
def build(self):
return sm
sm = ScreenManager()
sm.add_widget(MITMs1(name='MITMs1'))
if __name__=='__main__':
MITMtool().run()
答案 0 :(得分:0)
在字符串构造的中间有format(self.self.MAC)
。这就是为什么你得到关于没有self.self
。
输入错误并不重要,它只是来自kivy查询输入设备以查看可用的内容。