Example #1
0
    def enter(self):
        country = language.language("EN", "england").get()
        print country.get("title")
        print country.get("sub_title")
        print country.get("sub_title2")
        print country.get("sub_title3")
        print country.get("sub_title4")

        action = raw_input("> ")
        action = parsera.process_input(action, ["play"], ["them"])
        print "-" * 10

        if action == country.get("command1"):

            print "You ar starting a game with them"
            print "They gives you a riddle"
            print '"This thing runs but cannot walk, sometimes sings but never talks. '
            print 'Lacks arms, has hands; lacks a head but has a face."'
            action = raw_input("> ")
            action = parsera.process_input(action, ["clock"], [])
            print "-" * 10
            if action == "clock":
                print "You won a boat : + %s XP" % self.roomPoints
                global items
                items.append("Boat")
                global points
                points = self.roomPoints
                return "boat"
            else:
                return "lost"
        else:
            print "You give up this oppurtunity and walks around and do nothing"
            return "lost"
Example #2
0
    def process(self):
        if self.label[0].endswith('Hz'):
            self.x_value = range(10, 90, 10)
            self.label_x = language('频率 / MHz', 'Frequency (MHz)')
        elif self.label[0].startswith('ec') or self.label[0].startswith('lc'):
            self.x_value = range(32, 32 * 9, 32)
            self.label_x = language('阵元数目', 'Number of Elements')
            if len(self.label) == 7:
                self.x_value = range(64, 32 * 9, 32)
        elif self.label[0].startswith('rc'):
            self.x_value = range(512, 256 * 9, 256)
            self.label_x = language('图像行数', 'Number of Rows')
        else:
            pass

        self.update()
Example #3
0
	def get(self, **params):
		self.set_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')		
		module = self.get_argument('module', 'missing')
		if module == 'missing':
			self.clear()
			self.set_status(404)
			self.finish('Missing function call')
			return
		else:
			Log.Debug('Recieved a get call for module: ' + module)
	
#TODO
			''' Attempt to create a dynamic import, but so far, it sadly breaks access to the PMS API :-(
			import sys
			sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code'))
			mod = import_module(module)
			modClass = getattr(mod, module)()
			print 'GED1', dir(modClass)
			callFunction = getattr(modClass, 'reqprocess')
			self = modClass().reqprocess(self)
			'''

			

			if module == 'git':			
				self = git().reqprocess(self)
			elif module == 'logs':
				self = logs().reqprocess(self)
			elif module == 'pms':
				self = pms().reqprocess(self)
			elif module == 'settings':
				self = settings().reqprocess(self)
			elif module == 'findMedia':
				self = findMedia().reqprocess(self)
			elif module == 'jsonExporter':
#				self = jsonExporter().reqprocess(self)
				try:
					m = getattr(module)

				except Exception, e:
					print 'Ged json Exception: ' + str(e)




			elif module == 'language':
				self = language().reqprocess(self)
Example #4
0
	def get(self, **params):		
		module = self.get_argument('module', 'missing')
		if module == 'missing':
			self.clear()
			self.set_status(404)
			self.finish('Missing function call')
			return
		else:
			Log.Debug('Recieved a get call for module: ' + module)
	
#TODO
			''' Attempt to create a dynamic import, but so far, it sadly breaks access to the PMS API :-(
			import sys
			sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code'))
			mod = import_module(module)
			modClass = getattr(mod, module)()
			print 'GED1', dir(modClass)
			callFunction = getattr(modClass, 'reqprocess')
			self = modClass().reqprocess(self)
			'''

			if module == 'git':			
				self = git().reqprocess(self)
			elif module == 'logs':
				self = logs().reqprocess(self)
			elif module == 'pms':
				self = pms().reqprocess(self)
			elif module == 'settings':
				self = settings().reqprocess(self)
			elif module == 'findMedia':
				self = findMedia().reqprocess(self)
			elif module == 'language':
				self = language().reqprocess(self)
			elif module == 'plex2csv':
				self = plex2csv().reqprocess(self)
			elif module == 'wt':
				self = wt().reqprocess(self)
			elif module == 'scheduler':
				print 'Ged WebSrv Scheduler'
				self = scheduler().reqprocess(self)
			else:
				self.clear()
				self.set_status(412)
				self.finish('Unknown module call')
				return
Example #5
0
	def get(self, **params):		
		module = self.get_argument('module', 'missing')
		if module == 'missing':
			self.clear()
			self.set_status(404)
			self.finish('Missing function call')
			return
		else:
			Log.Debug('Recieved a get call for module: ' + module)
	
#TODO
			''' Attempt to create a dynamic import, but so far, it sadly breaks access to the PMS API :-(
			import sys
			sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code'))
			mod = import_module(module)
			modClass = getattr(mod, module)()
			print 'GED1', dir(modClass)
			callFunction = getattr(modClass, 'reqprocess')
			self = modClass().reqprocess(self)
			'''

			if module == 'git':			
				self = git().reqprocess(self)
			elif module == 'logs':
				self = logs().reqprocess(self)
			elif module == 'pms':
				self = pms().reqprocess(self)
			elif module == 'settings':
				self = settings().reqprocess(self)
			elif module == 'findMedia':
				self = findMedia().reqprocess(self)
			elif module == 'language':
				self = language().reqprocess(self)
			elif module == 'plex2csv':
				self = plex2csv().reqprocess(self)
			elif module == 'wt':
				self = wt().reqprocess(self)
			else:
				self.clear()
				self.set_status(412)
				self.finish('Unknown module call')
				return
Example #6
0
#tests, will research about python unit tests and will start implenting them.
import unittest
from language import language
from festival import festival
from datetime import date

#Language tests:
#test the greetings logic:
lang = language();
voice = festival();

#any language logic we test here
class language_test(unittest.TestCase):

	#test the greetings builder
	def test_greetings (self):
		#morning check
		self.assertEqual(lang.greet(11), "good morning")
		#afternoon check
		self.assertEqual(lang.greet(13),"good afternoon")
		#night check
		self.assertEqual(lang.greet(20),"good evening")

	#test the time format is the same
	def test_time_format (self):
		testday = date(1983, 7, 19)
		self.assertEqual(lang.time(testday),"Tuesday July 19 12:00AM")

	def test_summary_description (self):
		self.assertEqual(lang.summary_description(), "The weather expected today is")
Example #7
0
def command():

    #input command
    command = raw_input(':> ')

    #start checking for command precursors and decide what to do
    #when you find it

    if google in command:
        query = command.replace(google, "")  #remove the precursor command
        query = urllib.urlencode({'q': query})  #encode the query
        response = urllib.urlopen(
            'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' +
            query).read()  #send the query to google API
        json = m_json.loads(response)
        results = json['responseData']['results']  #gather the desired data

        #for each result, print the title and url
        for result in results:
            title = result['title']
            url = result['url']
            print(title + ';' + url)

    if openf.rstrip('\n') in command:
        query = command.replace("open ", "")  #remove precursor
        pgrm = "%s%s.lnk" % (directory.rstrip('\n'), query
                             )  #join directory and program name
        os.startfile(pgrm)
#		reactor.spawnProcess(processProtocol, pgrm) #execute
#		reactor.run()

#replace all data in data.txt with nil
    if "wipe cache" in command:
        f = open('data.txt', 'w')
        f.write('')
        f.close()

    #set variable to open new tab in browser
    new = 2

    if searchbrowser.rstrip('\n') in command:
        query = command.replace(searchbrowser, "")  #remove precursor
        url = ("http://www.google.com/search?q=" + query
               )  #append query to end of google search
        webbrowser.open(url, new=new)  #open url in new tab

    if duckbrowser in command:
        query = command.replace(duckbrowser, '')
        url = ("http://duckduckgo.com/?q=" + query)
        webbrowser.open(url, new=new)

    if lis in command:
        newdir = directory.replace("\\", "", 1)  #clean up directory
        os.system('dir ' + directory)  #list contents of shortcut directory

    if joke in command:
        random.choice(jokes)()

    if 'tries' in command:
        print 'Loops: %s' % tries

    if blog in command:
        post()

    if journal in command:
        document, article = write()

    if search in command:
        query = command.replace(search + ' ', "")  #remove precursor
        post = open('journal.txt', 'r')
        postf = str(post.read())

        root = etree.fromstring(postf)

        articles = root.xpath('//article[contains(@tags, "%s")]' % query)

        for article in articles:
            print etree.tostring(article, pretty_print=True)

    if word in command:
        language.language()

    if nick in command:
        site = raw_input('website>>')
        name = raw_input('nickname>>')
        nickdic[site] = name

    if add in command:
        name = raw_input('name>>')
        url = raw_input('url>>')
        config.set('nicknames', name, url)
        print 'Done!'

    #create array for possible quit commands
    shut = {'shut', 'quit', 'stop', 'kill', 'exit', 'close'}

    #check to see if entered command is in {shut} array
    if command in shut:
        quit()
    #if it isn't specific, check if the string contains the following...
    #this allows for custom strings to still execute quit
    #such as "shut up" or "kill me"
    elif "shut" in command:
        quit()
    elif "exit" in command:
        quit()
    elif "stop" in command:
        quit()
    elif "kill" in command:
        quit()
Example #8
0
def lang():
	get_value = request.form.get("bunsyo")
	lang = language.language(get_value)
	db_init(lang.run(),get_value)
	return render_template("send.html",lang=get_value,score=lang.run())
Example #9
0
import csv

import dbobject as db_obj
import dbfamily as db_fam
import dbweapontohit as db_w2h
import language as l
import epoch_span

# import EE databases
obj = db_obj.object_import()
fam = db_fam.family_import()
w2h = db_w2h.weapontohit_import()
lang = l.language()

# enter indices of needed object fields
name_index = 0
attack_index = 24
attack_speed_index = 11
hitpoints_index = 6
shock_armor_index = 25
arrow_armor_index = 26
pierce_armor_index = 27
gun_armor_index = 28
laser_armor_index = 29
missile_armor_index = 30
attackMode_index = 32
family_index = 2
epoch_index = 4
unitTypeID_index = 36
weapontohitID_index = 23
LanguageId_index = 84
Example #10
0
    def paint(self, painter: Painter):
        painter.setFont(QFont(language('SimSun', 'Times New Roman'), 12))

        sub = self.maximum - self.minimum
        if sub < 0.15:
            step = 0.01
        elif sub < 0.25:
            step = 0.02
        elif sub < 0.55:
            step = 0.04
        elif sub < 1.5:
            step = 0.1
        elif sub < 2.5:
            step = 0.2
        else:
            step = 0.3

        w = self.width()
        h = self.height()

        if step < 0.1:
            text_width = int(35 * scaling.ratio)
        else:
            text_width = int(30 * scaling.ratio)
        text_height = int(20 * scaling.ratio)

        # painter.drawText(QRect(0, 0, w, text_height), Qt.AlignCenter, self.title)
        painter.drawText(QRect(0, h - text_height, w, text_height), Qt.AlignCenter, self.label_x)
        # translate and rotate for paint vertical text
        painter.save()
        painter.translate(0, h)
        painter.rotate(-90)
        painter.drawText(QRect(0, 0, h, text_height), Qt.AlignCenter, self.label_y)
        painter.restore()

        # calculate min and max values #
        x_min = min(self.x_value)
        x_max = max(self.x_value)
        y_min = math.floor(self.minimum / step) * step
        y_max = math.ceil(self.maximum / step) * step

        horizontal_min = text_height + text_width
        horizontal_max = w - text_width / 2
        vertical_min = h - text_height * 2
        vertical_max = text_height

        # draw text on axis #
        horizontal_labels = list(map(str, self.x_value))
        horizontal_values = list(np.linspace(horizontal_min, horizontal_max, len(horizontal_labels)))
        for horizontal_x, label in zip(horizontal_values, horizontal_labels):
            if label == horizontal_labels[0] or label == horizontal_labels[-1]:
                painter.setPen(Pen(QBrush(Qt.black), 1.5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
            else:
                painter.setPen(Pen(QBrush(Qt.black), 0.8, Qt.DotLine, Qt.RoundCap, Qt.RoundJoin))

            current_point = PointF(horizontal_x, vertical_min)
            painter.draw_text_bottom(current_point, label, margin=2)
            painter.drawLine(current_point, PointF(horizontal_x, vertical_max))

        format_str = '{:.2f}' if step < 0.1 else '{:.1f}'
        vertical_labels = list(map(lambda v: format_str.format(v), np.arange(y_min, y_max + 1e-5, step)))
        vertical_values = list(np.linspace(vertical_min, vertical_max, len(vertical_labels)))
        for vertical_pos, label in zip(vertical_values, vertical_labels):
            if label == vertical_labels[0] or label == vertical_labels[-1]:
                painter.setPen(Pen(QBrush(Qt.black), 1.5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
            else:
                painter.setPen(Pen(QBrush(Qt.black), 0.8, Qt.DotLine, Qt.RoundCap, Qt.RoundJoin))

            current_point = PointF(horizontal_min, vertical_pos)

            if label != vertical_labels[0]:
                painter.draw_text_left(current_point, label)
            painter.drawLine(current_point, PointF(horizontal_max, vertical_pos))

        for line in self.lines:
            previous_point = None
            nums = line['line']

            shape = line['shape']
            shape_func = getattr(self, 'draw_{}'.format(shape))
            l = Qt.DotLine if line['is_dash'] else Qt.SolidLine

            for x, y in zip(self.x_value, nums):
                percent_x = (x - x_min) / (x_max - x_min)
                percent_y = (y - y_min) / (y_max - y_min)
                horizontal_pos = horizontal_max * percent_x + horizontal_min * (1 - percent_x)
                vertical_pos = vertical_max * percent_y + vertical_min * (1 - percent_y)
                current_point = PointF(horizontal_pos, vertical_pos)

                shape_func(painter, current_point)
                if previous_point:
                    painter.setPen(Pen(QBrush(Qt.black), 1.5, l, Qt.RoundCap, Qt.RoundJoin))
                    painter.drawLine(previous_point, current_point)
                previous_point = current_point

        left_width = 17 + SizeF.text_size('{}-45mm'.format(self.method), painter.font()).w
        right_width = 17 + SizeF.text_size('{}-45mm'.format(self.reversed_method), painter.font()).w
        legend_width = 3 + left_width + 5 + right_width

        if 'mm' in self.label_y:
            left_top = PointF(horizontal_max, vertical_max) + SizeF(-(legend_width + 5), 5)
        else:
            left_top = PointF(horizontal_max, vertical_min) + SizeF(-(legend_width + 5), -40)

        painter.setBrush(Qt.white)
        painter.setPen(Pen(Qt.black, 1.0, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawRect(QRectF(left_top, SizeF(legend_width, 35)))

        current = left_top + SizeF(10, 10)
        painter.setPen(Pen(QBrush(Qt.black), 1.5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawLine(current - SizeF(7, 0), current + SizeF(7, 0))
        self.draw_circle(painter, current)
        painter.draw_text_right(current, '{}-25mm'.format(self.method), margin=12)

        current += SizeF(0, 15)
        painter.setPen(Pen(QBrush(Qt.black), 1.5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawLine(current - SizeF(7, 0), current + SizeF(7, 0))
        self.draw_square(painter, current)
        painter.draw_text_right(current, '{}-45mm'.format(self.method), margin=12)

        current = left_top + SizeF(left_width + 5 + 7, 10)
        painter.setPen(Pen(QBrush(Qt.black), 1.5, Qt.DotLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawLine(current - SizeF(7, 0), current + SizeF(7, 0))
        self.draw_circle(painter, current)
        painter.draw_text_right(current, '{}-25mm'.format(self.reversed_method), margin=12)

        current += SizeF(0, 15)
        painter.setPen(Pen(QBrush(Qt.black), 1.5, Qt.DotLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawLine(current - SizeF(7, 0), current + SizeF(7, 0))
        self.draw_square(painter, current)
        painter.draw_text_right(current, '{}-45mm'.format(self.reversed_method), margin=12)

        painter.end()
Example #11
0
def webhook():
    global reqContext
    print(request.get_json(silent=True, force=True))
    reqContext = request.get_json(silent=True, force=True)
    print("webhook---->" + reqContext.get("result").get("action"))

    if reqContext.get("result").get("action") == "input.welcome.edwin":
        return welcome()
    elif reqContext.get("result").get("action") == "showpopularcategories":
        return showpopularcategories()
    elif reqContext.get("result").get("action") == "professionalcourses":
        return professional_courses.professionalcourses()
    elif reqContext.get("result").get("action") == "professionalcertificates":
        return professional_courses.professionalcertificates()
    elif reqContext.get("result").get("action") == "careeradvancement":
        return professional_courses.careeradvancement()
    elif reqContext.get("result").get("action") == "micromastersprograms":
        return professional_courses.micromastersprograms()
    elif reqContext.get("result").get("action") == "advancedskillsetcourses":
        return professional_courses.advancedskillsetcourses()
    elif reqContext.get("result").get("action") == "popularcourses":
        return popular_course.popularcourselist()
    elif reqContext.get("result").get("action") == "computerscience":
        return computer_science.computerscience()
    elif reqContext.get("result").get("action") == "data_and_statistics":
        return data_and_statistics.data_and_statistics()
    elif reqContext.get("result").get("action") == "business_management":
        return business_management.business_management()
    elif reqContext.get("result").get("action") == "language":
        return language.language()
    elif reqContext.get("result").get("action") == "economics_and_finance":
        return economics_and_finance.economics_and_finance()
    elif reqContext.get("result").get("action") == "engineering":
        return engineering.engineering()
    elif reqContext.get("result").get("action") == "humanities":
        return humanities.humanities()
    elif reqContext.get("result").get("action") == "life_sciences":
        return life_sciences.life_sciences()
    elif reqContext.get("result").get("action") == "science_courses":
        return science_courses.science_courses()
    elif reqContext.get("result").get("action") == "chemistry":
        return chemistry.chemistry()
    elif reqContext.get("result").get("action") == "electronics":
        return electronics.electronics()
    elif reqContext.get("result").get("action") == "environmental_studies":
        return environmental_studies.environmental_studies()
    elif reqContext.get("result").get("action") == "mathematics":
        return mathematics.mathematics()
    elif reqContext.get("result").get("action") == "medicine":
        return medicine.medicine()
    elif reqContext.get("result").get("action") == "physics":
        return physics.physics()
    elif reqContext.get("result").get("action") == "social_science":
        return social_science.social_science()
    elif reqContext.get("result").get("action") == "energy_and_earth_science":
        return energy_and_earth_science.energy_and_earth_science()
    elif reqContext.get("result").get("action") == "art_courses":
        return art_courses.art_courses()
    elif reqContext.get("result").get("action") == "architecture":
        return architecture.architecture()
    elif reqContext.get("result").get("action") == "art_and_culture":
        return art_and_culture.art_and_culture()
    elif reqContext.get("result").get("action") == "communication":
        return communication.communication()
    elif reqContext.get("result").get("action") == "design":
        return design.design()
    elif reqContext.get("result").get("action") == "food_and_nutrition":
        return food_and_nutrition.food_and_nutrition()
    elif reqContext.get("result").get("action") == "health_and_safety":
        return health_and_safety.health_and_safety()
    elif reqContext.get("result").get("action") == "history":
        return history.history()
    elif reqContext.get("result").get("action") == "music":
        return music.music()
    elif reqContext.get("result").get("action") == "law":
        return law.law()
    elif reqContext.get("result").get("action") == "BacktoWelcomeContent":
        return showpopularcategories()
    elif reqContext.get("result").get("action") == "BackToProfessionalCourses":
        return professional_courses.professionalcourses()
    else:
        print("Good Bye")
Example #12
0
def command():
	
	#input command
	command = raw_input(':> ')
	
	#start checking for command precursors and decide what to do
	#when you find it
	
	if google in command:
		query = command.replace(google, "") #remove the precursor command
		query = urllib.urlencode ({ 'q' : query }) #encode the query
		response = urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' + query).read() #send the query to google API
		json = m_json.loads(response)
		results = json['responseData']['results'] #gather the desired data
	
		#for each result, print the title and url
		for result in results:
			title = result['title']
			url = result['url']
			print (title + ';' + url)
		
	
	if openf.rstrip('\n') in command:
		query = command.replace("open ", "") #remove precursor
		pgrm = "%s%s.lnk" % (directory.rstrip('\n'), query) #join directory and program name
		os.startfile(pgrm)
#		reactor.spawnProcess(processProtocol, pgrm) #execute
#		reactor.run()
		
	#replace all data in data.txt with nil
	if "wipe cache" in command:
		f = open('data.txt', 'w')
		f.write('')
		f.close()
	
	#set variable to open new tab in browser
	new = 2	
	
	if searchbrowser.rstrip('\n') in command:
		query = command.replace(searchbrowser, "") #remove precursor
		url = ("http://www.google.com/search?q=" + query) #append query to end of google search
		webbrowser.open(url, new=new) #open url in new tab
		
	if duckbrowser in command:
		query = command.replace(duckbrowser, '')
		url = ("http://duckduckgo.com/?q=" + query)
		webbrowser.open(url, new=new)
		
	if lis in command:
		newdir = directory.replace("\\", "", 1) #clean up directory
		os.system('dir ' + directory) #list contents of shortcut directory
	
	if joke in command:
		random.choice(jokes)()
		
	if 'tries' in command:
		print 'Loops: %s' % tries
		
	if blog in command:
		post()
		
	if journal in command:
		document, article = write()
		
	if search in command:
		query = command.replace(search + ' ', "") #remove precursor
		post = open('journal.txt', 'r')
		postf = str(post.read())
		
		root = etree.fromstring(postf)
		
		articles = root.xpath('//article[contains(@tags, "%s")]' % query)
				
		for article in articles:
			print etree.tostring(article, pretty_print=True)
			
	if word in command:
		language.language()	
	
	if nick in command:
		site = raw_input('website>>')
		name = raw_input('nickname>>')
		nickdic[site] = name
		
	if add in command:
		name = raw_input('name>>')
		url = raw_input('url>>')
		config.set('nicknames', name, url)
		print 'Done!'
		
	#create array for possible quit commands
	shut = {'shut', 'quit', 'stop', 'kill', 'exit', 'close'}
	
	#check to see if entered command is in {shut} array
	if command in shut:
		quit()
	#if it isn't specific, check if the string contains the following...
	#this allows for custom strings to still execute quit
	#such as "shut up" or "kill me"
	elif "shut" in command:
		quit()
	elif "exit" in command:
		quit()
	elif "stop" in command:
		quit()
	elif "kill" in command:
		quit()