本文整理汇总了Python中plugin.Plugin类的典型用法代码示例。如果您正苦于以下问题:Python Plugin类的具体用法?Python Plugin怎么用?Python Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, global_calibrate,shared_pos,screen_marker_pos,screen_marker_state,atb_pos=(0,0)):
Plugin.__init__(self)
self.active = False
self.detected = False
self.publish = False
self.global_calibrate = global_calibrate
self.global_calibrate.value = False
self.shared_pos = shared_pos
self.pos = 0,0 # 0,0 is used to indicate no point detected
self.smooth_pos = 0.,0.
self.smooth_vel = 0.
self.sample_site = (-2,-2)
self.counter = 0
self.counter_max = 30
self.candidate_ellipses = []
self.show_edges = c_bool(0)
self.aperture = c_int(7)
self.dist_threshold = c_int(10)
self.area_threshold = c_int(30)
atb_label = "calibrate using handheld marker"
# Creating an ATB Bar is required. Show at least some info about the Ref_Detector
self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label,
help="ref detection parameters", color=(50, 50, 50), alpha=100,
text='light', position=atb_pos,refresh=.3, size=(300, 100))
self._bar.add_button("start", self.start, key='c')
示例2: make_plugin
def make_plugin(config):
smtp_config = SmtpConfig(config)
p = Plugin()
p.username = smtp_config.username
p.sendmail = SmtpSender(smtp_config)
return p
示例3: __init__
def __init__(self, g_pool,atb_pos=(0,0)):
Plugin.__init__(self)
self.active = False
self.detected = False
self.g_pool = g_pool
self.pos = None
self.smooth_pos = 0.,0.
self.smooth_vel = 0.
self.sample_site = (-2,-2)
self.counter = 0
self.counter_max = 30
self.candidate_ellipses = []
self.show_edges = c_bool(0)
self.aperture = 7
self.dist_threshold = c_int(10)
self.area_threshold = c_int(30)
self.world_size = None
self.stop_marker_found = False
self.auto_stop = 0
self.auto_stop_max = 30
atb_label = "calibrate using handheld marker"
# Creating an ATB Bar is required. Show at least some info about the Ref_Detector
self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label,
help="ref detection parameters", color=(50, 50, 50), alpha=100,
text='light', position=atb_pos,refresh=.3, size=(300, 100))
self._bar.add_button("start/stop", self.start_stop, key='c')
self._bar.add_var("show edges",self.show_edges, group="Advanced")
示例4: __init__
def __init__(self, g_pool, atb_pos=(0, 0)):
Plugin.__init__(self)
self.g_pool = g_pool
self.first_img = None
self.point = None
self.count = 0
self.detected = False
self.active = False
self.pos = None
self.r = 40.0 # radius of circle displayed
self.ref_list = []
self.pupil_list = []
atb_label = "calibrate using natural features"
self._bar = atb.Bar(
name=self.__class__.__name__,
label=atb_label,
help="ref detection parameters",
color=(50, 50, 50),
alpha=100,
text="light",
position=atb_pos,
refresh=0.3,
size=(300, 100),
)
self._bar.add_button("start/stop", self.start_stop, key="c")
示例5: __init__
def __init__(self, options):
self.options = options
self.results = []
self.group_plugin = Plugin.load_plugin(options.group)
self.flow_plugin = Plugin.load_plugin(options.flow)
if self.flow_plugin is None:
self.flow_plugin = FlowPlugin()
示例6: __init__
def __init__(self, teh_bot):
Plugin.__init__(self, teh_bot)
random.seed()
self.command_dictionary = {
"choice": self.random,
"question": self.question,
"random": self.random,
"scale": self.scale,
}
self.command_info = {
"question": [
" %squestion QUESTION" % self.command_prefix,
"Returns a positive or a negative response to your question",
],
"scale": [
" %sscale STATEMENT" % self.command_prefix,
" %sscale" % self.command_prefix,
"Scales your statment in procent",
"(random number between 1 and 100)",
],
"random": [
" %srandom CHOICE1 CHOICE2 CHOICE3" % self.command_prefix,
" %srandom CHOICE1, CHOICE2, CHOICE3" % self.command_prefix,
" %srandom CHOICE1 or CHOICE2 or CHOICE3" % self.command_prefix,
"Makes a random choice of the ones provided",
" %srandom NUMBER1 - NUMBER2" % self.command_prefix,
" %srandom NUMBER1 to NUMBER2" % self.command_prefix,
"Selects a random number between the two provided",
],
}
示例7: __init__
def __init__(self):
logging.debug('Plugin manager initializing')
# This will be set later, unable to activate plugins untill set
self.config = None
self.plugins = {}
self.plugin_bases = {}
for plugin_base in Plugin.__subclasses__():
plugin_name = plugin_base.__name__
self.plugin_bases[plugin_name] = plugin_base
self.plugins[plugin_name] = []
logging.debug('Searching for plugins')
plugins_found = self.find_plugins(Plugin.__subclasses__())
for i, plugin_base in enumerate(Plugin.__subclasses__()):
plugin_type = plugin_base.__name__
for plugin in plugins_found[i]:
self.plugins[plugin_type].append(plugin)
# list of active plugins
self.active = {}
for key in self.plugins:
self.active[key] = []
示例8: __init__
def __init__(self,g_pool,atb_pos=(0,0)):
Plugin.__init__(self)
self.window_should_open = False
self.window_should_close = False
self._window = None
self.fullscreen = c_bool(0)
self.realdata = c_bool(False)
self.x = c_float(0)
self.y = c_float(0)
self.blink_time = c_float(1)
self.should_blink = False
self.blink_start = None
atb_label = "android coordinate plugin"
# Creating an ATB Bar.
self._bar = atb.Bar(name =self.__class__.__name__, label=atb_label,
help="ref detection parameters", color=(50, 50, 50), alpha=100,
text='light', position=atb_pos,refresh=.3, size=(300, 100))
self._bar.add_var("real data", self.realdata)
self._bar.add_var("X", self.x)
self._bar.define("min=0 max=1 step=0.01", "X")
self._bar.add_var("Y", self.y)
self._bar.define("min=0 max=1 step=0.01", "Y")
self._bar.add_var("blink time", self.blink_time, min=0,max=10,step=0.05,help="Simulated blink time")
# self._bar.define("min=0 max=10000 step=50", "blink time")
self._bar.add_button("simulate blink", self.schedule_blink)
示例9: __init__
def __init__(self):
Plugin.__init__(self)
self.dispatcher = Dispatcher()
self.dispatcher.define('learn', self.cmdDefine, access='member', argc=2)
self.dispatcher.define('define', self.cmdDefine, access='member', argc=2)
self.dispatcher.define('forget', self.cmdForget, access='member', argc=1)
self.dispatcher.define('definfo', self.cmdDefInfo, access='moderator', argc=1)
示例10: execute
def execute(self, data):
Plugin.init(self, data)
self.target = data.get('in')
output = '%s.%s' %(self.target, self.suffix)
data['in'] = output
if self.skip:
return data
io = open(self.target, 'r')
oo = open(output, 'w')
for i, l in enumerate(io):
ss = l.strip().split(self.mr_delimiter)
try:
k = ss[0]
v = ss[1]
except:
continue
oo.write('%s%s%s\n' %(v, self.mr_delimiter, k))
oo.close()
io.close()
Plugin.terminate(self, data)
return data
示例11: delete
def delete(self, key):
try:
plugin = Plugin(key)
except DoesNotExist:
abort(404)
plugin.delete(plugin.key)
return {'result': 'success'}
示例12: plugin_delete
def plugin_delete(key):
message = None
if request.method == 'POST':
show_form = False
try:
plugin = Plugin(key)
title = 'Plugin {} version {} deleted'.format(plugin.name, plugin.version)
plugin.delete(key)
log("Plugin %s has been deleted" % key)
except DoesNotExist:
return render_error('<b>{}</b> does not exists'.format(key))
else:
try:
plugin = Plugin(key)
title = 'Confirm deletion of Plugin {} version {}?'.format(plugin.name, plugin.version)
show_form = True
log("Plugin %s deletion confirmation asked" % key)
except DoesNotExist:
return render_error('{} does not exists'.format(key))
return render_template('delete.html',
title=title,
plugin=plugin,
show_form=show_form,
message=message)
示例13: handle
def handle(self, client, msg):
token = msg['body'].split(' ')
try:
if token[0] == '+':
Channel.channels[token[1]].plugins.append(token[2])
msg.reply("Plugin {0} in {1} has beend activated".format(token[2], token[1])).send()
elif token[0] == '-':
Channel.channels[token[1]].plugins.remove(token[2])
msg.reply("Plugin {0} in {1} has beend deactivated".format(token[2], token[1])).send()
elif token[0] == 'reload':
Plugin.plugins = []
Plugin.load_all()
msg.reply("Plugins reloaded!").send()
elif token[0] == 'list':
plugins = []
for p in Plugin.plugins:
plugins.append(p.name)
msg.reply("Plugins loaded: {0}".format(', '.join(plugins))).send()
elif token[0] == 'active':
msg.reply("Plugins active in {0}: {1}".format(Channel.channels[token[1]].jid, ', '.join(Channel.channels[token[1]].plugins))).send()
except:
pass
示例14: onLoad
def onLoad(self, bot):
Plugin.onLoad(self, bot)
self._users = bot.getDb().table('users')
self._userData = {}
for row in self._users.getAll():
self._userData[row['mask']] = row
self._loadUsers()
示例15: __init__
def __init__( self, address="225.1.1.1", port=5200, interface="0.0.0.0" ):
Plugin.__init__(self, "broadcast")
self.address = address
self.port = port
self.interface = interface
try:
# Instantiate a UDP socket
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
# Allow address reuse
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Set the packets TTL
self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_TTL, 1)
# Do not loop messages back to the local sockets
self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_LOOP, 0)
# Bind to the port
self.sock.bind(('', self.port))
# Set the interface to perform the multicast on
self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.interface))
# Apply for messages sent to the specified address
self.sock.setsockopt(socket.SOL_IP,
socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(self.address) + socket.inet_aton(self.interface))
self._initialized = True
except socket.error:
pass