2012-09-19 12:10:51 +00:00
|
|
|
from Tank.Core import AbstractPlugin
|
|
|
|
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import textwrap
|
|
|
|
|
|
|
|
class TipsAndTricksPlugin(AbstractPlugin, AbstractInfoWidget):
|
2012-09-19 12:28:28 +00:00
|
|
|
SECTION = 'tips'
|
|
|
|
|
2012-09-19 12:10:51 +00:00
|
|
|
def __init__(self, core):
|
|
|
|
AbstractPlugin.__init__(self, core)
|
|
|
|
lines = open(os.path.dirname(__file__) + '/tips.txt').readlines()
|
2012-09-19 12:40:00 +00:00
|
|
|
line = random.choice(lines)
|
|
|
|
self.section = line[:line.index(':')]
|
|
|
|
self.tip = line[line.index(':')+1:].strip()
|
2012-09-19 12:46:10 +00:00
|
|
|
self.disable = 0
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_key():
|
2012-09-19 12:46:10 +00:00
|
|
|
return __file__
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def configure(self):
|
2012-09-19 12:28:28 +00:00
|
|
|
self.disable = int(self.get_option('disable', '0'))
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def prepare_test(self):
|
2012-09-19 12:28:28 +00:00
|
|
|
if not self.disable:
|
|
|
|
try:
|
|
|
|
console = self.core.get_plugin_of_type(ConsoleOnlinePlugin)
|
2012-09-19 12:46:10 +00:00
|
|
|
except KeyError, ex:
|
2012-09-19 12:28:28 +00:00
|
|
|
self.log.debug("Console not found: %s", ex)
|
|
|
|
console = None
|
|
|
|
|
|
|
|
if console:
|
|
|
|
console.add_info_widget(self)
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def start_test(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def end_test(self, retcode):
|
|
|
|
self.log.debug("End2")
|
|
|
|
|
|
|
|
def get_index(self):
|
|
|
|
return 10000 # really last index
|
|
|
|
|
|
|
|
|
|
|
|
def render(self, screen):
|
2012-09-19 13:19:57 +00:00
|
|
|
line = screen.markup.WHITE + "Tips & Tricks => " + self.section + screen.markup.RESET + ":\n "
|
2012-09-19 12:40:00 +00:00
|
|
|
line += "\n ".join(textwrap.wrap(self.tip, screen.right_panel_width-1))
|
2012-09-19 12:10:51 +00:00
|
|
|
return line
|
|
|
|
|