i cannot post any topics inthe plugin support forum so i post this here....
i'm working on my fist plugin and i want to check if an file exist,
this is my code for now:
Code: Select all
import eg
import datetime
import time
import os
eg.RegisterPlugin(
name = "My New Plugin",
author = "Me",
version = "0.0.1",
kind = "other",
description = "This is an example plugin."
)
eg.RegisterPlugin()
class MyNewPlugin(eg.PluginBase):
def __init__(self):
self.AddAction(HelloWorld)
self.AddAction(Test)
self.AddAction(LogFileHandler)
print "MyNewPlugin is inited."
def __start__(self, myString):
print "MyNewPlugin is started with parameter: " + myString
def __stop__(self):
print "MyNewPlugin is stopped."
def __close__(self):
print "MyNewPlugin is closed."
def Configure(self, myString=""):
panel = eg.ConfigPanel()
textControl = wx.TextCtrl(panel, -1, myString)
panel.sizer.Add(textControl, 1, wx.EXPAND)
while panel.Affirmed():
panel.SetResult(textControl.GetValue())
class HelloWorld(eg.ActionBase):
def __call__(self):
print "Hello World!"
class Test(eg.ActionBase):
def __call__(self):
print "Test!"
filename = "LogFile.txt"
if os.path.exists(filename):
print "file exists"
else:
print "file not exists"
class LogFileHandler(eg.ActionBase):
def __call__(self, myString):
now = datetime.datetime.now()
TimeDateNow = now.ctime()
newLine =TimeDateNow + " : " +myString +".\n"
today = datetime.date.today()
file = open("LogFile.txt", "a")
file.write(newLine)
file.close()
return
def Configure(self, myString=""):
panel = eg.ConfigPanel()
textControl = wx.TextCtrl(panel, -1, myString)
panel.sizer.Add(textControl, 1, wx.EXPAND)
while panel.Affirmed():
panel.SetResult(textControl.GetValue())
Code: Select all
class Test(eg.ActionBase):
def __call__(self):
print "Test!"
filename = "LogFile.txt"
if os.path.exists(filename):
print "file exists"
else:
print "file not exists"
First i tried to run the code of the class test in a python decompiler and also gave me no errors.
When i try it in eventghost i get the following errors:
Code: Select all
Error while loading plugin-file KPI.
Traceback (most recent call last) (1462):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginManager.py", line 178, in LoadPluginInfo
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
File "C:\Program Files (x86)\EventGhost\plugins\KPI\__init__.py", line 52
filename = "LogFile.txt"
^
IndentationError: unexpected indent
KPI
Error while loading plugin-file KPI.
Traceback (most recent call last) (1462):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginManager.py", line 178, in LoadPluginInfo
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
File "C:\Program Files (x86)\EventGhost\plugins\KPI\__init__.py", line 52
filename = "LogFile.txt"
^
IndentationError: unexpected indent
KPI
---> Welcome to EventGhost <---
Can't find action: MyNewPlugin.PrintString(u'helloooooo')
Autostart
Plugin: Task Create/Switch Events
Python Script
Plugin: KPI #
Error starting plugin: KPI
Plugin not found!
Main.OnInit
Task.Activated.EventGhostTHANKS in ADVANCED