Exemple #1
0
    def __init__(self, fname=None):
        # Default values, see explanations below:        
        taskDic = {
        'taskName': 'total energy',
        'tolerance': '1',
        'nMaxSteps': '10'
        }
        Estimator.__init__(self,fname)
        Launcher.__init__(self,fname)                
        # value to converge with respect to k-points or energy cutoffs
        # currently can be 'total energy', 'single phonon', or 'geometry':
        self.taskName = self.config.get('Task', 'taskName')

        # convergence criteria in percents:        
        self.tolerance = self.config.getfloat('Task','tolerance')
        
        # maximum number of optimization steps:
        self.nMaxSteps = self.config.getint('Task','nMaxSteps')  
        
        self.lookupTable = {
        'total energy' : (self.pwscfLauncher, self.getTotalEnergy),
        'single phonon': (self.singlePhononLauncher, self.getSinglePhonon),
        'geometry'     : (self.pwscfLauncher, self.getLatticeParameters),
        'multiple phonon': (self.multiPhononLauncher, self.getMultiPhonon)
        }        
        
        assert self.lookupTable.has_key(self.taskName), "Convergence \
    def __init__(self, command):
        '''
        @param command: [_executable,_prompt,_exitCommand,_cleanUpCommand] 
        '''    
        logger.debug("Creating Shell Launcher.")
        Thread.__init__(self)
        Launcher.__init__(self)
        
    
        self._executable = command[0]
        self._prompt =  command[1]
        self._exitCommand =  command[2]
        self._cleanUpCommand = command[3]
        
        self.__out = None
        self.__err = None
        self.__process = None
        self.__pid = None
        self.__returnCode = None
        
        self._launchProcess()
        
        self._outQueue = Queue.Queue()
        self._errQueue = Queue.Queue()

        self._startThreads()
        self._startExecutable()
        
        self._params = None
        self._result = None
        self._resultFile = None
Exemple #3
0
def run():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-c', '--config', metavar='FILE', help="path to configuration file",
        default="~/gtlaunch.json",
    )
    parser.add_argument(
        '-v', '--verbose', help="verbose output",
        action='store_true',
    )
    parser.add_argument(
        '-V', '--version', action='version',
        version='%%(prog)s %s' % __version__,
    )
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument(
        '-l', '--list', help="list all projects", action='store_true',
    )
    group.add_argument(
        dest='project', metavar='PROJECT', help="project label", nargs='?',
    )
    args = parser.parse_args()
    try:
        launcher = Launcher(args)
        launcher.run()
    except LauncherError as e:
        print("Launcher error: {}".format(e))
        sys.exit(1)
Exemple #4
0
def main():
    ears = Listener()

    from launcher import Launcher
    app = Launcher()
    app.add_property("pandora")
    app.add_property("firefox")
    ears.listen(app)

    return 0
Exemple #5
0
    def __init__(self, fname):
        
        Launcher.__init__(self, fname)
        Property.__init__(self, fname)

        self.qeConfig = QEConfig(self.pwscfInput)
        self.qeConfig.parse()

        self.structure = QEStructure(self.pwscfInput)

        self.dispersion = dispersion.Dispersion(self)

#        self._kpts = self.getkPoints()
        self._ekincutoff = self.getEkincutoff()
Exemple #6
0
 def launchExecutor(self, framework_id, info, executor_info, directory, resources):
     fid = framework_id.value
     eid = executor_info.executor_id.value
     logger.info("Launching %s (%s) in %s with resources %s for framework %s", 
             eid, executor_info.command.value, directory, resources, fid)
     pid = os.fork()
     assert pid >= 0
     if pid:
         logger.info("Forked executor at %d", pid)
         pinfo = ProcessInfo(framework_id, executor_info.executor_id, pid, directory)
         self.infos.setdefault(fid, {})[eid] = pinfo
         self.pids[pid] = pinfo
         self.slave.executorStarted(framework_id, executor_info.executor_id, pid)
     else:
         #pid = os.setsid()
         # copy UPID of slave
         launcher = Launcher(framework_id, executor_info.executor_id, executor_info.command, 
                 info.user, directory, self.slave)
         launcher.run()
Exemple #7
0
def main():

	launcher = Launcher(sys.argv)
	obj = launcher.launch()
	
	Log.log(sys.argv)

	try:
		obj.poll()
	except BaseException as e:

		#This is here for debugging purposes
		if isinstance(e, Exception):
			Log.log(e)
			my_log = open(Log.log_file, 'a')
			traceback.print_exc(file=my_log)

		obj.cleanup()

		sys.exit(0)
 def __init__(self, initParams=None):
     '''
     
     '''    
     logger.debug("Creating Python Script Launcher...")
     
     
     Process.__init__(self)
     Launcher.__init__(self, initParams)
     
     self.globalVariables= {}
     self.localVariables= {}
     
     self.queueResult = Queue()
     self.queueOutput = Queue()
     
     self.localVariables = {}
     self.globalVariables = {}
     self.result = None
     self.output = None
     
     self.timeout = None
     self.command = None
Exemple #9
0
    def run(self, problem_id, domain_template, problem_template,
                 facts_pdkb, goals_pdkb):

        """
        Execute the planner and return the parsed output.
        Before the planner is executed the pddl problem file is created
        dynamically by inserting the knowledge base (kb_files) and the current
        goals (goal_files) at the right location in the problem template.

        @param problem_id           The id for the particular
                                    problem/domain set

        @param domain_template      The path of the pddl domain template

        @param problem_template     The name of the pddl problem template that
                                    contains special insertion marks

        @param facts_pdkb           The fact files to be inserted in
                                    the pddl problem file

        @param goals_pdkb           The goal files to be inserted in the pddl
                                    problem file

        """

        # insert the PDKB files into the PDDL templates
        (domain_file, problem_file) = compile_PDKB_to_PDDL(
            problem_id, domain_template, problem_template,
            facts_pdkb, goals_pdkb)

        # launch the planner and redirect output to parser
        l = Launcher(domain_file, problem_file)
        l.launch()
        p = Parser(l.get_output())

        if print_planner_output:
            print l.get_output()

        # return the parsed plan
        return p
Exemple #10
0
 def __init__(self):
     self.laucher = Launcher()
     self.pub = rospy.Publisher('move_base_simple/goal', PoseStamped, queue_size=10) 
#!/usr/bin/python2
from launcher import Launcher

local_tmp_folder = '/opt/joulupukki/scripts/tmp/packages_folder_nightly_windows/'
local_ddl_folder = '/opt/joulupukki/scripts/repos/windows/'

launcher = Launcher(
    'example-windows', 
    'https://some.depot.com/example-windows', 
    'windows', 
    'http://buildmachine-01.joulupukkidomain.com/v3/users/someone/',
    local_tmp_folder,
    local_ddl_folder,
)


build_id = launcher.launch_build()
if launcher.wait_build(build_id):
    archive = launcher.download_build(build_id)
    launcher.extract_build(archive)
    launcher.move_package('win32/example-windows-nightly.exe')
    print("Build succeeded !")
    
    # After build command
    launcher.after_build_cmds([
        "rsync -arv --delete "+local_ddl_folder+" [email protected]:/var/www/example/windows"
    ])
else:
    print("Build timed-out or failed.")
Exemple #12
0
 def start_launcher(self):
     """Start the Teledoc Launcher Process"""
     cmd_q = Queue()
     self.launcher = Launcher(self.ns, cmd_q=cmd_q)
     self._start_process("launcher")
Exemple #13
0
class HelloWorld(object):
    def __init__(self):
        self.laucher = Launcher()

    @cherrypy.expose
    def index(self):

        # <input type="button" value="goalA" onclick="location.href='192.168.3.3:8080/goalA_to'">
        # ERIC https://github.com/VirtuosoEric/robot_web_service/blob/pn60/home.html

        f = open("t.html", "r")
        return f

    @cherrypy.expose
    def start_roscore(self):
        self.laucher.roslauncher()
        return 'start roscore'

    @cherrypy.expose
    def kill_roscore(self):
        self.laucher.kill_roscore()
        return 'kill roscore'

    @cherrypy.expose
    def goalA_to(self):
        pub = rospy.Publisher('move_base_simple/goal',
                              PoseStamped,
                              queue_size=10)
        goal = PoseStamped()
        goal.header.frame_id = "map"
        goal.header.stamp = rospy.Time.now()
        goal.pose.position.x = 0
        goal.pose.position.y = -1
        goal.pose.position.z = 0
        goal.pose.orientation.w = 1.0
        pub.publish(goal)
        return 'goal to!'

    @cherrypy.expose
    def goalA_leave(self):
        pub = rospy.Publisher('move_base_simple/goal',
                              PoseStamped,
                              queue_size=10)
        goal = PoseStamped()
        goal.header.frame_id = "map"
        goal.header.stamp = rospy.Time.now()
        goal.pose.position.x = 0
        goal.pose.position.y = 1
        goal.pose.position.z = 0
        goal.pose.orientation.w = 1.0
        pub.publish(goal)
        return 'goal leave!'

    @cherrypy.expose
    def goalB_to(self):
        # f = open("latop.html", "r")
        return 'Hello!'

    @cherrypy.expose
    def goalB_leave(self):
        # f = open("latop.html", "r")
        return 'Hello!'

    @cherrypy.expose
    def goalC_to(self):
        # f = open("latop.html", "r")
        return 'Hello!'
Exemple #14
0
from config import schedule_list, vk_api_token as token
from launcher import Launcher

from schedule.receive_data import ReceiveSchedule

launcher = Launcher(token)

ReceiveSchedule.start(schedule_list)
launcher.start()
Exemple #15
0
from region.transform import RegionMorph
from launcher import Launcher

"""
Simple example that validates that the calculator is present on the screen.
This example does not use the Launcher() class so it assumes that the application
is already running.  Results can be found in the /results directory. 
"""

# Change logging level verbosity
#EntityLoggerProxy.getLogger().setLevel(TRACE)
Config.setScreenshotLoggingLevel(TRACE)


# Launch the Calculator binary
textedit = Launcher.run('TextEdit')
logger = EntityLoggerProxy(textedit)

# Type some text in the text area
textedit[TextEdit.TEXT_AREA].type("This is a demo of SikuliFramework")

# Resize the application size 4 times
for i in range(0,4):
    
    # Get the current application region
    region = textedit.validate().region
    
    # Alternate between growing / shrinking application width
    offset = 100 * (1 - ((i % 2)*2))
    
    # Modify the size of current application region
Exemple #16
0
 def __init__(self, username, password):
     print '11'
     self.launcher = Launcher(username, password)
     print '22'
     self.username = username
     self.password = password
Exemple #17
0
class Operation():
    def __init__(self, username, password):
        print '11'
        self.launcher = Launcher(username, password)
        print '22'
        self.username = username
        self.password = password

    def publish(self, text):
        driver = self.launcher.login_mobile()
        time.sleep(20)
        html = driver.page_source
        with open("publish1.html", "wb") as f:
            f.write(html)
        driver.save_screenshot("publish1.png")
        driver.find_element_by_xpath('//input[@type="submit"]').click()
        print "publish111111"
        html = driver.page_source
        with open('publish.html', 'wb') as f:
            f.write(html)
        driver.save_screenshot('publish.png')
        driver.find_element_by_xpath(
            '//textarea[@name="xc_message"]').send_keys(text)
        print "publish222222"
        driver.find_element_by_xpath('//input[@name="view_post"]').click()
        print "publish333333"

        time.sleep(60)

        html = driver.page_source
        with open("publish2.html", "wb") as f:
            f.write(html)
        driver.save_screenshot("publish.png")
        driver.quit()

        print "publish Success!!!!!!"

        return [True, '']

    def mention(self, username, text):
        driver = self.launcher.login()
        #driver,display = self.launcher.login()
        try:
            # 退出通知弹窗进入页面
            time.sleep(1)
            try:
                #driver.find_element_by_xpath('//div[@class="_n8 _3qx uiLayer _3qw"]').click()
                driver.find_element_by_xpath(
                    '//div[@class="_1k67 _cy7"]').click()
                print "mention Success11111111111111111111111"
            except BaseException, e:
                print "mention Position11111111111111111", e
                pass

            try:
                driver.find_element_by_xpath(
                    '//textarea[@title="分享新鲜事"]').click()
                driver.find_element_by_xpath(
                    '//textarea[@title="分享新鲜事"]').send_keys(text)
            except:
                driver.find_element_by_xpath(
                    '//div[@class="_1mwp navigationFocus _395 _1mwq _4c_p _5bu_ _34nd _21mu _5yk1"]'
                ).click()
                driver.find_element_by_xpath(
                    '//div[@class="_1mwp navigationFocus _395 _1mwq _4c_p _5bu_ _34nd _21mu _5yk1"]'
                ).send_keys(text)
            time.sleep(2)
            try:
                driver.find_element_by_xpath(
                    '//table[@class="uiGrid _51mz"]/tbody/tr[1]/td[1]//a/div'
                ).click()
            except:
                driver.find_element_by_xpath(
                    '//table[@class="uiGrid _51mz _5f0n"]/tbody/tr[2]/td[2]//a/div'
                ).click()
            time.sleep(1)
            driver.find_element_by_xpath(
                '//input[@aria-label="你和谁一起?"]').send_keys(username)
            driver.find_element_by_xpath(
                '//input[@aria-label="你和谁一起?"]').send_keys(Keys.ENTER)
            time.sleep(1)
            try:
                driver.find_element_by_xpath(
                    '//button[@class="_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft"]'
                ).click()
            except:
                driver.find_element_by_xpath(
                    '//button[@data-testid="react-composer-post-button"]'
                ).click()
            time.sleep(5)
            return [True, '']
        except Exception as e:
            return [False, e]
Exemple #18
0
class Share():
    def __init__(self, username, password):
        self.launcher = Launcher(username, password)
        self.es = Es_fb()
        self.list = []
        self.share_list, self.driver = self.launcher.get_share_list()
        self.update_time = int(time.time())

    def get_share(self):

        for url in self.share_list:
            self.driver.get(url)
            time.sleep(120)
            # 退出通知弹窗进入页面

            try:
                self.driver.find_element_by_xpath(
                    '//div[@class="_n8 _3qx uiLayer _3qw"]').click()
            except:
                pass

            page = self.driver.page_source
            self.driver.save_screenshot('get_share000.png')

            #for ea in self.driver.find_elements_by_xpath('//div[@role="feed"]/div'):
            #for ea in divs:
            #	for each in ea.find_elements_by_xpath('./div'):
            try:
                author_name = self.driver.find_element_by_xpath(
                    '//table[@role="presentation"]/tbody/tr/td[2]/div/h3/strong/a'
                ).text
            except:
                author_name = ''
            print author_name

            try:
                author_id = ''.join(
                    re.search(re.compile('id%3D(\d+)&'), url).group(1))
            except:
                author_id = ''
            print author_id
            #		try:
            #			pic_url = each.find_element_by_xpath('./div[2]/div/div[2]/div/div/a/div/img').get_attribute('src')
            #		except:
            #			pic_url = 'None'

            try:
                content = self.driver.find_element_by_xpath(
                    '/html/body/div/div/div[2]/div/div[1]/div[1]/div/div[1]/div[2]'
                ).text
            except:
                content = ''

            try:
                timestamp = int(
                    re.search(
                        re.compile('&quot;publish_time&quot;:(\d+),'),
                        page.replace(' ',
                                     '').replace('\n',
                                                 '').replace('\t',
                                                             '')).group(1))
            except:
                timestamp = ''
            print timestamp

            try:
                mid = ''.join(
                    re.search(re.compile('fbid%3D(\d+)%'), url).group(1))
            except:
                mid = ''
            print mid

            try:
                root_mid = ''.join(
                    re.search(
                        re.compile(
                            '&quot;original_content_id&quot;:&quot;(\d+)&quot;'
                        ), page).group(1))
            except:
                root_mid = ''
            print root_mid

            try:
                root_text = self.driver.find_element_by_xpath(
                    '/html/body/div/div/div[2]/div/div[1]/div[1]/div/div[1]/div[3]/div[2]/div/div/div[2]'
                ).text.replace(' ', '').replace('\n', '').replace('\t', '')
            except:
                root_text = ''
            print root_text

            item = {'uid':author_id, 'nick_name':author_name, 'mid':mid, 'timestamp':timestamp,\
               'text':content, 'update_time':self.update_time, 'root_text':root_text, 'root_mid':root_mid}
            self.list.append(item)

        self.driver.quit()
        return self.list

    def save(self, indexName, typeName, list):
        self.es.executeES(indexName, typeName, list)
Exemple #19
0
	def __init__(self):
		self.launcher = Launcher('18538728360','zyxing,0513')
		self.driver = self.launcher.login()
Exemple #20
0
class Operation():
	def __init__(self):
		self.launcher = Launcher('18538728360','zyxing,0513')
		self.driver = self.launcher.login()

	def publish(self):
		self.driver.find_element_by_xpath('//div[@class="_4bl9 _42n-"]').click()
		time.sleep(2)
		self.driver.find_element_by_xpath('//div[@class="_1mwp navigationFocus _395 _1mwq _4c_p _5bu_ _34nd _21mu _5yk1"]').send_keys('测试消息3')
		self.driver.find_element_by_xpath('//button[@class="_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft"]').click()

	def mention(self):
		self.driver.find_element_by_xpath('//div[@class="_4bl9 _42n-"]').click()
		time.sleep(3)
		self.driver.find_element_by_xpath('//div[@class="_1mwp navigationFocus _395 _1mwq _4c_p _5bu_ _34nd _21mu _5yk1"]').send_keys('测试消息4')
		time.sleep(1)
		self.driver.find_element_by_xpath('//table[@class="uiGrid _51mz _5f0n"]/tbody/tr[2]/td[2]/span/a/div').click()
		self.driver.find_element_by_xpath('//input[@aria-label="你和谁一起?"]').send_keys('xerxes zhang')
		self.driver.find_element_by_xpath('//input[@aria-label="你和谁一起?"]').send_keys(Keys.ENTER)
		time.sleep(1)
		self.driver.find_element_by_xpath('//button[@class="_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft"]').click()

	def follow(self):
		driver = self.launcher.target_page()
		driver.find_element_by_xpath('//a[@class="_42ft _4jy0 _4jy4 _517h _51sy"]').click()

	def not_follow(self):
		driver = self.launcher.target_page()
		chain = ActionChains(driver)
		implement = driver.find_element_by_xpath('//button[@class="_42ft _4jy0 _3oz- _52-0 _4jy4 _517h _51sy"]')
		chain.move_to_element(implement).perform()
		driver.find_element_by_xpath('//a[@ajaxify="/ajax/follow/unfollow_profile.php?profile_id=100022568024116&location=1"]').click()

# 私信(未关注)
	def send_message(self):
		#发送给未关注的用户
		driver = self.launcher.target_page()
		url = driver.find_element_by_xpath('//a[@class="_51xa _2yfv _3y89"]/a[2]').get_attribute('href')
		driver.get('https://www.facebook.com' + url)
		driver.find_element_by_xpath('//div[@class="_1mf _1mj"]').send_keys('test')
		driver.find_element_by_xpath('//div[@class="_1mf _1mj"]').send_keys(Keys.ENTER)
# 私信(已关注)
	def send_message2(self):
		#发送给已关注的用户
		driver = self.launcher.target_page()
		url = driver.find_element_by_xpath('//a[@class="_51xa _2yfv _3y89"]/a[1]').get_attribute('href')
		driver.get('https://www.facebook.com' + url)
		driver.find_element_by_xpath('//div[@class="_1mf _1mj"]').send_keys('test')
		driver.find_element_by_xpath('//div[@class="_1mf _1mj"]').send_keys(Keys.ENTER)

# 测试id
#id = 'tl_unit_-8182132709408758851'

	def like(self, id):
		driver = self.launcher.target_page()
		driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[1]/div[1]/div/div[1]/div/div/div/span[1]/div/a'%id).click()


	def comment(self, id):
		driver = self.launcher.target_page()
		driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[2]/div/div[2]/div/div[2]/div/div/div/div/div'%id).click()
		driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[2]/div/div[2]/div/div[2]/div/div/div/div/div'%id).send_keys('test comment')
		driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[2]/div/div[2]/div/div[2]/div/div/div/div/div'%id).send_keys(Keys.ENTER)

# 分享
	def share(self):
		driver = self.launcher.target_page()
		#action_chains = ActionChains(driver)
		driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[1]/div[1]/div/div[1]/div/div/div/span[3]//span'%id).click()
		time.sleep(3)
		driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[1]/div[1]/div/div[1]/div/div/div/span[3]/div/span'%id).click()
		#action_chains.key_down(Keys.CONTROL).click(el)
		#driver.find_element_by_xpath('//div[@id="%s"]/div/div[2]/div[2]/form/div[1]/div[1]/div/div[1]/div/div/div/span[3]/div/span'%id).click()
		time.sleep(3)
		driver.find_element_by_xpath('//ul[@class="_54nf"]/li[2]').click()
		time.sleep(8)
		driver.find_element_by_xpath('//div[@class="_1mwp navigationFocus _395  _21mu _5yk1"]').click()
		driver.find_element_by_xpath('//div[@class="notranslate _5rpu"]/div/div/div').send_keys('test')
		time.sleep(3)
		driver.find_element_by_xpath('//button[@data-testid="react_share_dialog_post_button"]').click()


# 好友
	def friends(self,uid):
		uid = '100022568024116'
		self.driver.get('https://www.facebook.com/'+ uid +'/friends')
		self.driver.execute_script("""
			(function () {
			var y = 0;
			var step = 100;
			window.scroll(0, 0);
			function f() {
			if (y < document.body.scrollHeight) {
			y += step;
			window.scroll(0, y);
			setTimeout(f, 150);
			} else {
			window.scroll(0, 0);
			document.title += "scroll-done";
			}
			}
			setTimeout(f, 1500);
			})();
			""")
		time.sleep(3)
		while True:
			if "scroll-done" in driver.title:
				break
			else:
				time.sleep(3)
		for each in driver.find_elements_by_xpath('//div[@id="contentArea"]/div/div[2]/div/div/div/div[2]/div//ul//li'):
			try:
				pic_url = each.find_element_by_xpath('./div/a/img').get_attribute('src')
				name = each.find_element_by_xpath('./div/div/div[2]/div/div[2]/div/a').text
				id = ''.join(re.findall(re.compile('id=(\d+)'),each.find_element_by_xpath('./div/div/div[2]/div/div[2]/div/a').get_attribute('data-hovercard')))
			except Exception as e:
				pass
Exemple #21
0
class Like():
	def __init__(self, username, password):
		self.launcher = Launcher(username, password)
		self.driver = self.launcher.login()
		self.like_list = self.launcher.get_like_list()
		self.es = Es_fb()
		self.list = []
		self.update_time = int(time.time())

	def get_like(self):
		try:
			for url in self.like_list:
				self.driver.get(url)
				time.sleep(1)
				# 退出通知弹窗进入页面
				try:
					self.driver.find_element_by_xpath('//div[@class="_n8 _3qx uiLayer _3qw"]').click()
				except:
					pass

				try:
					text = self.driver.find_element_by_xpath('//div[@class="_5pbx userContent _22jv _3576"]').text
				except Exception as e:
					text = 'None'
				try:
					try:
						timestamp = int(self.driver.find_element_by_xpath('//abbr[@class="_5ptz"]').get_attribute('data-utime'))
					except:
						timestamp = int(self.driver.find_element_by_xpath('//abbr[@class="_5ptz timestamp livetimestamp"]').get_attribute('data-utime'))
				except:
					timestamp = 0
				try:
					mid = ''.join(re.findall(re.compile('/(\d+)'),self.driver.find_element_by_xpath('//a[@class="_5pcq"]').get_attribute('href')))
				except:
					mid = 0
				# 进入点赞列表页
				self.driver.get(self.driver.find_element_by_xpath('//a[@class="_2x4v"]').get_attribute('href'))
				time.sleep(5)
				# 退出通知弹窗进入页面
				try:
					self.driver.find_element_by_xpath('//div[@class="_n8 _3qx uiLayer _3qw"]').click()
				except:
					pass
				for each in self.driver.find_elements_by_xpath('//li[@class="_5i_q"]'):
					try:
						author_name = each.find_element_by_xpath('./div/div/div/div[1]/div[2]/div/a').text
					except:
						author_name = 'None'
					try:
						author_id = ''.join(re.findall(re.compile('id=(\d+)'),each.find_element_by_xpath('./div/div/div/div[1]/div[2]/div/a').get_attribute('data-hovercard')))
					except:
						author_id = 'None'
					try:
						pic_url = each.find_element_by_xpath('./div/a/div/img').get_attribute('src')
					except:
						pic_url = 'None'

					item = {'uid':author_id, 'photo_url':pic_url, 'nick_name':author_name, 'timestamp':timestamp, 'text':text, 'update_time':self.update_time, 'root_text':text, 'root_mid':mid}
					self.list.append(item)
		finally:
			self.driver.close()
		return self.list

	def save(self, indexName, typeName, list):
		self.es.executeES(indexName, typeName, list)
Exemple #22
0
	def __init__(self,username, password):
		self.launcher = Launcher(username, password)
		self.driver = self.launcher.login()
def test_launcher_constructor_succeed():
    cloud_adapter = MagicMock()
    launcher = Launcher(cloud_adapter)
    assert isinstance(launcher, Launcher)
    assert launcher.cloud_adapter == cloud_adapter
Exemple #24
0
class Comment():
    def __init__(self, username, password):
        self.launcher = Launcher(username, password)
        self.es = Es_fb()
        self.comment_list, self.driver = self.launcher.get_comment_list()
        self.list = []
        self.update_time = int(time.time())

    def date2timestamp(self, date):
        date = date.replace(u'月', '-').replace(u'日', '').replace(' ', '')
        if date == '刚刚':
            timestamp = int(time.time())
            return timestamp
        if u'上午' in date:
            date = date.replace(u'上午', ' ')
        if u'下午' in date:
            if date.split(u'下午')[1].split(':')[0] == '12':
                date = date.replace(u'下午', ' ')
            elif eval(date.split(u'下午')[1].split(':')[0]) < 12:
                date = date.split(u'下午')[0] + ' ' + str(
                    eval(date.split(u'下午')[1].split(':')[0]) +
                    12) + ':' + date.split(u'下午')[1].split(':')[1]
        if u'年' not in date and u'分钟' not in date and u'小时' not in date:
            date = str(
                time.strftime('%Y-%m-%d', time.localtime(
                    time.time())).split('-')[0]) + '-' + date
        if u'年' in date and u'分钟' not in date and u'小时' not in date:
            date = date.replace(u'年', '-')

        if u'分钟' in date:
            timestamp = int(
                time.time()) - int(re.search(r'(\d+)', date).group(1)) * 60
            return timestamp
        if u'小时' in date:
            timestamp = int(time.time()) - int(
                re.search(r'(\d+)', date).group(1)) * 60 * 60
            return timestamp

        try:
            timestamp = int(time.mktime(time.strptime(date, '%Y-%m-%d')))
        except:
            timestamp = int(time.mktime(time.strptime(date, '%Y-%m-%d %H:%M')))
        return timestamp

    def get_comment(self):
        print 'comment_list', self.comment_list
        for url in self.comment_list:
            self.driver.get(url)
            time.sleep(1)

            try:
                root_text = self.driver.find_element_by_xpath(
                    '//div[@id="m_story_permalink_view"]/div[1]/div/div[1]/div[2]'
                ).text
            except BaseException, e:
                root_text = ''
            print root_text

            try:
                root_mid = ''.join(
                    re.search(re.compile('fbid%3D(\d+)%'), url).group(1))
                print 'root_mid', root_mid
            except BaseException, e:
                print "get_comment Position44444444", e
                root_mid = ''
            print root_mid

            for each in self.driver.find_elements_by_xpath(
                    '//div[@id="m_story_permalink_view"]/div[2]/div/div[4]/div'
            ):
                if u' 查看更多评论' in each.text:
                    break

                try:
                    author_name = each.find_element_by_xpath('./div/h3/a').text
                except BaseException, e:
                    print "get_comment Position66666666", e
                    try:
                        author_name = each.find_element_by_xpath(
                            './div[1]/div/div/div[2]/div/div/div/div[1]/div/span/span[1]/a'
                        ).text
                    except:
                        author_name = ''
                print author_name

                try:
                    author_id = ''.join(
                        re.findall(
                            re.compile('id=(\d+)'),
                            each.find_element_by_xpath(
                                './div/h3/a').get_attribute('href')))
                except:
                    author_id = ''

                #try:
                #	print 7777777777
                #	pic_url = each.find_element_by_xpath('./div/div/div/div[1]/a/img').get_attribute('src')
                #except:
                #	pic_url = 'None'
                try:
                    content = each.find_element_by_xpath('./div/div[1]').text
                except:
                    try:
                        content = each.find_element_by_xpath(
                            './div/div[1]/span/span').text
                    except:
                        content = 'Emoji'
                print content

                try:
                    ti = self.date2timestamp(
                        str(each.text.replace(' ', '').split('·')[5]))
                except:
                    try:
                        ti = self.date2timestamp(
                            str(each.text.replace(' ', '').split('·')[4]))
                    except:
                        ti = 0

                try:
                    if re.findall(
                            r'id=(\d+)&',
                            each.find_element_by_xpath(
                                './div/h3/a').get_attribute('href')):
                        comment_type = 'receive'
                        text = content
                    else:
                        comment_type = 'make'
                        text = content
                except:
                    comment_type = 'unknown'
                    text = ''

                self.list.append({
                    'uid': author_id,
                    'nick_name': author_name,
                    'mid': root_mid,
                    'timestamp': ti,
                    'text': content,
                    'update_time': self.update_time,
                    'root_text': root_text,
                    'root_mid': root_mid,
                    'comment_type': comment_type
                })
Exemple #25
0
class Mention():
    def __init__(self, username, password):
        self.launcher = Launcher(username, password)
        self.mention_list, self.driver = self.launcher.get_mention_list()
        self.es = Es_fb()
        self.list = []
        self.update_time = int(time.time())

    def date2timestamp(self, date):
        date = date.replace(u'月', '-').replace(u'日', '').replace(' ', '')
        if date == '刚刚':
            timestamp = int(time.time())
            return timestamp
        if u'上午' in date:
            date = date.replace(u'上午', ' ')
        if u'下午' in date:
            if date.split(u'下午')[1].split(':')[0] == '12':
                date = date.replace(u'下午', ' ')
            elif eval(date.split(u'下午')[1].split(':')[0]) < 12:
                date = date.split(u'下午')[0] + ' ' + str(
                    eval(date.split(u'下午')[1].split(':')[0]) +
                    12) + ':' + date.split(u'下午')[1].split(':')[1]
        if u'年' not in date and u'分钟' not in date and u'小时' not in date:
            date = str(
                time.strftime('%Y-%m-%d', time.localtime(
                    time.time())).split('-')[0]) + '-' + date
        if u'年' in date and u'分钟' not in date and u'小时' not in date:
            date = date.replace(u'年', '-')
        if u'分钟' in date:
            timestamp = int(
                time.time()) - int(re.search(r'(\d+)', date).group(1)) * 60
            return timestamp
        if u'小时' in date:
            timestamp = int(time.time()) - int(
                re.search(r'(\d+)', date).group(1)) * 60 * 60
            return timestamp
        try:
            timestamp = int(time.mktime(time.strptime(date, '%Y-%m-%d')))
        except:
            timestamp = int(time.mktime(time.strptime(date, '%Y-%m-%d %H:%M')))
        return timestamp

    def get_mention(self):

        for url in self.mention_list:
            self.driver.get(url)
            time.sleep(1)

            try:
                nick_name = self.driver.find_element_by_xpath(
                    '//div[@id="root"]/div[1]/div[1]/div/div[1]/div[1]/table/tbody/tr/td[2]/div/h3/strong/a'
                ).text
            except:
                nick_name = ''
            print nick_name

            try:
                uid = re.findall(
                    r'id=(\d+)',
                    self.driver.find_element_by_xpath(
                        '//div[@id="root"]/div[1]/div[1]/div/div[1]/div[1]/table/tbody/tr/td[2]/div/h3/strong/a'
                    ).get_attribute('href'))[0]
            except:
                uid = ''
            print uid

            try:
                timestamp = self.date2timestamp(
                    self.driver.find_element_by_xpath(
                        '//div[@id="root"]/div[1]/div[1]/div/div[2]/div/abbr').
                    text)
            except:
                timestamp = 0
            print timestamp

            try:
                text = self.driver.find_element_by_xpath(
                    '//div[@id="root"]/div[1]/div[1]/div/div[1]/div[2]').text
            except:
                text = ''
            print text

            try:
                mid = ''.join(re.findall(re.compile('fbid%3D(\d+)'), url))
            except:
                mid = ''
            print mid

            item = {
                'uid': uid,
                'nick_name': nick_name,
                'mid': mid,
                'timestamp': timestamp,
                'text': text,
                'update_time': self.update_time
            }
            self.list.append(item)

        for i in self.list:
            self.driver.get('https://m.facebook.com/profile.php?id=' +
                            str(i['uid']))
            try:
                photo_url = self.driver.find_element_by_xpath(
                    '//div[@id="m-timeline-cover-section"]/div[1]/div[2]/div[1]/div/a/img'
                ).get_attribute('src')
            except:
                try:
                    photo_url = self.driver.find_element_by_xpath(
                        '//div[@id="m-timeline-cover-section"]/div[2]/div/div[1]/div[1]/a/img'
                    ).get_attribute('src')
                except:
                    photo_url = self.driver.find_element_by_xpath(
                        '//div[@id="m-timeline-cover-section"]/div[2]/div/div[1]/a/img'
                    ).get_attribute('src')
            i['photo_url'] = photo_url

        self.driver.quit()
        return self.list

    def save(self, indexName, typeName, mention_list):
        self.es.executeES(indexName, typeName, mention_list)
Exemple #26
0
class Comment():
    def __init__(self, username, password):
        self.launcher = Launcher(username, password)
        self.driver = self.launcher.login()
        self.es = Es_fb()
        self.comment_list = self.launcher.get_comment_list()
        self.list = []
        self.update_time = int(time.time())

    def get_comment(self):
        try:
            for url in self.comment_list:
                self.driver.get(url)
                time.sleep(1)
                # 退出通知弹窗进入页面
                try:
                    self.driver.find_element_by_xpath(
                        '//div[@class="_n8 _3qx uiLayer _3qw"]').click()
                except:
                    pass

                try:
                    try:
                        root_text = self.driver.find_element_by_xpath(
                            '//div[@role="feed"]/div[1]/div[1]/div[2]/div[1]/div[2]/div[2]'
                        ).text
                    except:
                        root_text = self.driver.find_element_by_xpath(
                            '//div[@role="feed"]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]'
                        ).text
                except:
                    root_text = 'None'
                try:
                    try:
                        root_mid = ''.join(
                            re.findall(
                                re.compile('story_fbid=(\d+)'),
                                self.driver.find_element_by_xpath(
                                    '//div[@role="feed"]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/div/span[3]/span/a'
                                ).get_attribute('href')))
                    except:
                        root_mid = ''.join(
                            re.findall(
                                re.compile('story_fbid=(\d+)'),
                                self.driver.find_element_by_xpath(
                                    '//div[@role="feed"]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/div/span[3]/span/a'
                                ).get_attribute('href')))
                except:
                    root_mid = 'None'
                for each in self.driver.find_elements_by_xpath(
                        '//div[@aria-label="评论"]'):
                    try:
                        try:
                            author_name = each.find_element_by_xpath(
                                './div/div/div/div[2]/div/div/div/div/div/span/span[1]/a'
                            ).text
                        except:
                            author_name = each.find_element_by_xpath(
                                './div/div/div/div[2]/div/div/div/span/span[1]/a'
                            ).text
                    except:
                        author_name = 'None'
                    try:
                        try:
                            author_id = ''.join(
                                re.findall(
                                    re.compile('id=(\d+)'),
                                    each.find_element_by_xpath(
                                        './div/div/div/div[2]/div/div/div/div/div/span/span[1]/a'
                                    ).get_attribute('data-hovercard')))
                        except:
                            author_id = ''.join(
                                re.findall(
                                    re.compile('id=(\d+)'),
                                    each.find_element_by_xpath(
                                        './div/div/div/div[2]/div/div/div/span/span[1]/a'
                                    ).get_attribute('data-hovercard')))
                    except:
                        author_id = 'None'
                    try:
                        pic_url = each.find_element_by_xpath(
                            './div/div/div/div[1]/a/img').get_attribute('src')
                    except:
                        pic_url = 'None'
                    try:
                        content = each.find_element_by_xpath(
                            './div/div/div/div[2]/div/div/div/div/div/span/span[2]/span/span/span/span'
                        ).text
                    except:
                        content = each.find_element_by_xpath(
                            './div/div/div/div[2]/div/div/div/span/span[2]/span/span/span/span'
                        ).text
                    try:
                        ti = int(
                            each.find_element_by_xpath(
                                './div/div/div/div[2]/div/div/div[2]/span[4]/a/abbr'
                            ).get_attribute('data-utime'))
                    except:
                        ti = int(
                            each.find_element_by_xpath(
                                './div/div/div/div[2]/div/div/div[2]/span[5]/a/abbr'
                            ).get_attribute('data-utime'))
                    self.list.append({'uid':author_id, 'photo_url':pic_url, 'nick_name':author_name, 'mid':root_mid, 'timestamp':ti, 'text':content,\
                          'update_time':self.update_time, 'root_text':root_text, 'root_mid':root_mid})
        finally:
            self.driver.quit()
            # self.launcher.display.stop()
            self.launcher.display.popen.kill()
        return self.list

    def save(self, indexName, typeName, list):
        self.es.executeES(indexName, typeName, list)
Exemple #27
0
from launcher import Launcher

if __name__ == '__main__':
    Launcher().run_program()
Exemple #28
0
    "num_term_partition": 100,
    # "num_params" : 23695351,
    # "num_params" : 1000,
    "num_params": 262144,
    "num_iter": 20,
    "is_sgd": False,
    "staleness": 0,
    "combine_type": "kShuffleCombine",
    "num_param_per_part": 2369,
}

scheduler_params = {
    "dag_runner_type": "sequential",
}

env_params = (
    "GLOG_logtostderr=true "
    "GLOG_v=-1 "
    "GLOG_minloglevel=0 "
    # this is to enable hdfs short-circuit read (disable the warning info)
    # change this path accordingly when we use other cluster
    # the current setting is for proj5-10
    # "LIBHDFS3_CONF=/data/opt/course/hadoop/etc/hadoop/hdfs-site.xml"
    "LIBHDFS3_CONF=/data/opt/hadoop-2.6.0/etc/hadoop/hdfs-site.xml")

dump_core = False
l = Launcher(schedulerfile, progfile, hostfile, common_params,
             scheduler_params, program_params, env_params, dump_core)

l.Launch(sys.argv)
def main(script_name, argv):
    species, read_type, job_name, dir_out, feature_reference, fastq_list, fastq_list_r2, libtype, master, \
        expected_cells, forced_cells, chemistry, nosecondary, r1_length, r2_length, genome_build, transcriptome, \
        vdj_genome, detect_doublet, project, run, toolset, cores_per_sample, verbose, sync, sample_name_list, \
        master_mode, toolchain, target_panel, mem_free = parse_arguments(script_name, argv)

    library_type = "scRNASeq"
    if not read_type:
        read_type = "paired"
    if not job_name:
        job_name = "{}_job".format(library_type)
    if not run:
        run = "{}_run".format(library_type)
    if not expected_cells:
        expected_cells = "3000"
    if not forced_cells:
        forced_cells = "NA"
    if not nosecondary:
        nosecondary = "FALSE"
    if not cores_per_sample:
        cores_per_sample = "8"
    if not target_panel:
        target_panel = "NA"
    additional_options = {
        "feature_reference": feature_reference,
        "genome_build": genome_build,
        "genome": transcriptome,
        "transcriptome": transcriptome,
        "vdj_genome": vdj_genome,
        "expected_cells": expected_cells,
        "forced_cells": forced_cells,
        "chemistry": chemistry,
        "nosecondary": nosecondary,
        "r1_length": r1_length,
        "r2_length": r2_length,
        "target_panel": target_panel,
        "maxmem": mem_free
    }
    if not toolset:
        toolset = "count+vdj+qc"
    if detect_doublet and "doubletdetection" not in toolset:
        toolset += "+doubletdetection"
    global_config = GlobalConfig(species, read_type, TEMPLATE, WORKFLOW_NAME,
                                 toolset)
    if species == "human":
        global_config_tool_template_name = GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_TOOLCHAIN2 \
            if toolchain == "Cellranger_v6" else GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_TOOLCHAIN1
    elif species == "mouse":
        global_config_tool_template_name = GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_MOUSE_TOOLCHAIN2 \
            if toolchain == "Cellranger_v6" else GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_MOUSE_TOOLCHAIN1
    else:
        raise RuntimeError(
            'Failed to determine "species" parameter. Available species: "human" and "mouse"'
        )

    global_config_path = global_config.create(
        global_config_tool_template_name,
        additional_options,
        cores_per_sample=cores_per_sample)
    if os.path.isdir(fastq_list):
        fastq_list = FastqSampleManifest(read_type).create_by_folder(
            fastq_list, WORKFLOW_NAME, library_type)
    elif 'fastq.gz' in str(fastq_list).split(',')[0]:
        sample_libtype = list(str(libtype).split(',')) if libtype else None
        sample_master = list(str(master).split(',')) if master else None
        sample_name_list = list(
            str(sample_name_list).split(',')) if sample_name_list else None
        fastq_list = FastqSampleManifest(read_type).create_by_list(
            list(str(fastq_list).split(',')),
            list(str(fastq_list_r2).split(',')),
            WORKFLOW_NAME,
            library_type,
            sample_libtype=sample_libtype,
            sample_master=sample_master,
            sample_names=sample_name_list)
    study_config = StudyConfig(job_name,
                               dir_out,
                               fastq_list,
                               None,
                               library_type,
                               run,
                               project=project)
    study_config_path = study_config.parse(workflow=WORKFLOW_NAME)
    Launcher.launch(global_config_path,
                    study_config_path,
                    sync,
                    java_path=global_config.java_path,
                    verbose=verbose,
                    master=master_mode)
Exemple #30
0
 def __init__(self):
     self.laucher = Launcher()
Exemple #31
0
class Share():
    def __init__(self, username, password):
        self.launcher = Launcher(username, password)
        self.api = self.launcher.api()
        self.driver = self.launcher.login()
        self.driver.get('https://twitter.com/i/notifications')
        self.es = Es_twitter()
        self.lis = self.driver.find_elements_by_xpath(
            '//li[@data-item-type="activity"]')
        self.list = []

    def get_share(self):
        root_uid = self.api.me().id
        for li in self.lis:
            try:
                type = li.get_attribute('data-component-context')
                if type == "quote_activity" or type == "retweet_activity":
                    try:
                        mid = li.get_attribute('data-item-id')
                        user_name = li.find_element_by_xpath(
                            './div/div[2]/div[1]/a/span[1]').text
                        #user_screen_name = li.find_element_by_xpath('./div/div[2]/div[1]/a/span[2]').text
                        user_id = li.find_element_by_xpath(
                            './div/div[2]/div[1]/a').get_attribute(
                                'data-user-id')
                        timestamp = int(
                            li.find_element_by_xpath(
                                './div/div[2]/div[1]/small/a/span').
                            get_attribute('data-time'))
                        content = li.find_element_by_xpath(
                            './div/div[2]/div[2]/p').text
                        #root_user_name = li.find_element_by_xpath('./div/div[2]/div[3]/div/div/div[1]/div[1]/div[1]/b').text
                        root_user_screen_name = li.find_element_by_xpath(
                            './div/div[2]/div[3]/div/div/div[1]/div[1]/div[1]/span[3]/b'
                        ).text
                        root_content = li.find_element_by_xpath(
                            './div/div[2]/div[3]/div/div[1]/div[1]/div[1]/div[2]'
                        ).text
                    except:
                        mid = li.get_attribute('data-item-id')
                        user_name = li.find_element_by_xpath(
                            './div/div/div/div[2]/div/a').text
                        user_id = li.find_element_by_xpath(
                            './div/div/div/div[2]/div/a').get_attribute(
                                'data-user-id')
                        timestamp = int(
                            li.find_element_by_xpath(
                                './div/div/div/div[2]/div/div/div/span').
                            get_attribute('data-time'))
                        content = 'None'
                        root_uid = li.find_element_by_xpath(
                            './div/div/div/div[2]/div[2]/div/div/div'
                        ).get_attribute('data-user-id')
                        root_user_screen_name = li.find_element_by_xpath(
                            './div/div/div/div[2]/div[2]/div/div/div'
                        ).get_attribute('data-screen-name')
                        root_content = li.find_element_by_xpath(
                            './div/div/div/div[2]/div[2]/div/div/div/div/div/div[2]'
                        ).text

                    item = {
                        'user_name': user_name,
                        #'nick_name':user_screen_name,
                        'uid': user_id,
                        'timestamp': timestamp,
                        'text': content,
                        #'root_user_name':root_user_name,
                        'root_nick_name': root_user_screen_name,
                        'root_uid': root_uid,
                        'root_text': root_content,
                        'mid': mid
                    }
                    self.list.append(item)
            except:
                pass
        return self.list

    def save(self, indexName, typeName, list):
        self.es.executeES(indexName, typeName, list)
Exemple #32
0
## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
############################################################################

import sys
import os

from PySide import QtGui

import qtdemo_rc

from displaywidget import DisplayWidget
from displayshape import PanelShape
from launcher import Launcher

if __name__ == "__main__":
    # Make sure we run from the right directory.  (I don't think this should be
    # necessary.)
    dir = os.path.dirname(__file__)

    if dir:
        os.chdir(dir)

    app = QtGui.QApplication(sys.argv)
    launcher = Launcher()
    if not launcher.setup():
        sys.exit(1)
    launcher.show()
    sys.exit(app.exec_())
Exemple #33
0
from launcher import Launcher

if __name__ == '__main__':
    l = Launcher()
    l.run()
Exemple #34
0
from launcher import Launcher
Launcher.start_game()

Exemple #35
0
RegionScreen.setConfig(Config)

Finder.setLogger(EntityLoggerProxy)
Finder.setConfig(Config)
Finder.setTransform(Transform)

MultiResultProxy.setEntitySearcher(Searcher)

Formatter.setTool(Tool)
Formatter.setConfig(Config)

EntityTransform.setConfig(Config)

Canvas.setDefaultDrawingStrategy(SegmentDrawingStrategy)

Launcher.setLogger(EntityLoggerProxy)

## Boot

logger = EntityLoggerProxy()
logger.info("[SikuliFramework] Booting.. SikuliVersion=%s" %
            Env.getSikuliVersion())

# Works on all platforms
slash = "\\" if Env.getOS() == OS.WINDOWS else "/"

# Add image libraries (searched in order)
addImagePath(Config.imageBaseline + slash + "os" + slash +
             str(Env.getOS()).lower() + slash +
             str(Env.getOSVersion(True)).lower() + slash + Config.language)
addImagePath(Config.imageBaseline + slash + "os" + slash +
Exemple #36
0
from es import Es_fb
from launcher import Launcher


class Online():
    def __init__(self):
        pass

    def get_online(self):
        name_list = []
        status_list = []
        for each in driver.find_elements_by_xpath(
                '//li[@class="_42fz"]/a/div/div[3]'):
            name_list.append(each.text)
        for each in driver.find_elements_by_xpath(
                '//li[@class="_42fz"]/a/div/div[2]'):
            try:
                each.find_element_by_xpath('./div/span')
                status = 'online'
                status_list.append(status)
            except Exception as e:
                status = 'None'
                status_list.append(status)
        z = zip(name_list, status_list)
        dict = dict({name, status} for name, status in z)


if __name__ == '__main__':
    fb = Launcher('18538728360', 'zyxing,0513')
    driver = fb.login()
    online = Online()
def launch():
    launch = Launcher()
    if launch.process(request):
        return jsonify(launch.result)
    else:
        abort(launch.error)
## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
############################################################################

import sys
import os

from PySide2 import QtGui

import qtdemo_rc

from displaywidget import DisplayWidget
from displayshape import PanelShape
from launcher import Launcher

if __name__ == "__main__":
    # Make sure we run from the right directory.  (I don't think this should be
    # necessary.)
    dir = os.path.dirname(__file__)

    if dir:
        os.chdir(dir)

    app = QtGui.QApplication(sys.argv)
    launcher = Launcher()
    if not launcher.setup():
        sys.exit(1)
    launcher.show()
    sys.exit(app.exec_())
Exemple #39
0
class Mention():
    def __init__(self, username, password):
        self.launcher = Launcher(username, password)
        self.mention_list, self.driver, self.display = self.launcher.get_mention_list(
        )
        self.es = Es_fb()
        self.list = []
        self.update_time = int(time.time())

    def get_mention(self):
        try:
            for url in self.mention_list:
                self.driver.get(url)
                time.sleep(1)
                # 退出通知弹窗进入页面
                try:
                    self.driver.find_element_by_xpath(
                        '//div[@class="_n8 _3qx uiLayer _3qw"]').click()
                except:
                    pass

                for each in self.driver.find_elements_by_xpath(
                        '//div[@id="contentArea"]'):
                    try:
                        try:
                            author_name = each.find_element_by_xpath(
                                './div/div/div[3]/div/div/div/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/h5/span/span/span/a'
                            ).text
                        except:
                            author_name = each.find_element_by_xpath(
                                './div/div/div/div/div/div/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/h5/span/span/span/a'
                            ).text
                    except:
                        author_name = 'None'
                    try:
                        try:
                            author_id = ''.join(
                                re.findall(
                                    re.compile('id=(\d+)'),
                                    each.find_element_by_xpath(
                                        './div/div/div[3]/div/div/div/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/h5/span/span/span/a'
                                    ).get_attribute('data-hovercard')))
                        except:
                            author_id = ''.join(
                                re.findall(
                                    re.compile('id=(\d+)'),
                                    each.find_element_by_xpath(
                                        './div/div/div/div/div/div/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/h5/span/span/span/a'
                                    ).get_attribute('data-hovercard')))
                    except:
                        author_id = 'None'
                    try:
                        try:
                            pic_url = each.find_element_by_xpath(
                                './div/div/div[3]/div/div/div/div[2]/div/div[2]/div/div/a/div/img'
                            ).get_attribute('src')
                        except:
                            pic_url = each.find_element_by_xpath(
                                './div/div/div/div/div/div/div[2]/div/div[2]/div/div/a/div/img'
                            ).get_attribute('src')
                    except:
                        pic_url = 'None'
                    try:
                        try:
                            ti = int(
                                each.find_element_by_xpath(
                                    './div/div/div[3]/div/div/div/div[2]/div/div[2]/div/div/div/div[2]/div/div/div[2]/div/span[3]/span/span/a/abbr'
                                ).get_attribute('data-utime'))
                        except:
                            ti = int(
                                each.find_element_by_xpath(
                                    './div/div/div/div/div/div/div[2]/div/div[2]/div/div/div/div[2]/div/div/div[2]/div/span[3]/span/a/abbr'
                                ).get_attribute('data-utime'))
                    except:
                        ti = 'None'
                    try:
                        content = each.find_element_by_xpath(
                            './div/div/div/div/div/div/div[2]/div/div[2]/div[2]/p'
                        ).text
                    except:
                        content = 'None'
                    try:
                        try:
                            mid = ''.join(
                                re.findall(
                                    re.compile('/(\d+)'),
                                    each.find_element_by_xpath(
                                        './div/div/div[3]/div/div/div/div[2]/div/div[2]/div/div/div/div[2]/div/div/div[2]/div/span[3]/span/span/a'
                                    ).get_attribute('href')))
                        except:
                            mid = ''.join(
                                re.findall(
                                    re.compile('/(\d+)'),
                                    each.find_element_by_xpath(
                                        './div/div/div/div/div/div/div[2]/div/div[2]/div/div/div/div[2]/div/div/div[2]/div/span[3]/span/a'
                                    ).get_attribute('href')))
                    except:
                        mid = 'None'
                    item = {
                        'uid': author_id,
                        'photo_url': pic_url,
                        'nick_name': author_name,
                        'mid': mid,
                        'timestamp': ti,
                        'text': content,
                        'update_time': self.update_time
                    }
                    self.list.append(item)
        finally:
            self.driver.quit()
            self.display.popen.kill()
        return self.list

    def save(self, indexName, typeName, list):
        self.es.executeES(indexName, typeName, list)
 def launch(self):
     self.entity = Launcher.run('Calculator')
Exemple #41
0
class Retweet():
	def __init__(self):
		self.driver = Launcher('*****@*****.**','zyxing,0513').login()
		self.driver.find_element_by_xpath('//input[@id="search-query"]').send_keys('lvleilei1')
		self.driver.find_element_by_xpath('//input[@id="search-query"]').send_keys(Keys.ENTER)
		time.sleep(10)
		self.driver.find_element_by_xpath('//ul[@class="AdaptiveFiltersBar-nav"]/li[3]/a').click()
		time.sleep(10)
		self.driver.find_element_by_xpath('//div[@class="Grid Grid--withGutter"]/div[1]/div/div/a').click()
		time.sleep(10)
		self.driver.find_element_by_xpath('//a[@data-nav="tweets_with_replies_toggle"]').click()
		time.sleep(10)
		self.api = Launcher('*****@*****.**','zyxing,0513').api()

		self.id_list = []

	def id(slef,screen_name):
		for each in self.api.user_timeline(screen_name):
			id = each.id
			text = each.text
			self.id_list.append({'id':id,'text':text})
		return self.id_list

	def do_retweet(id):
		self.api.create_favorite(id)
"""
USB Missile launcher scratch interface.
Written by P. Dring
https://github.com/pddring/usb-missile-launcher

"""
from launcher import Launcher
import scratch

# connect to rocket launcher
r = Launcher()

# connect to scratch
try:
	s = scratch.Scratch()
except:
	print("Error: You must open scratch before running this program")
	exit()
time = 200

print("Connected to USB Missile launcher... waiting for messages from Scratch")
print("Press Ctrl+C to quit")
# Loop continuously to wait for messages from scratch
try:
	while True:
		# get a message broadcast from scratch
		msg = s.receive()
		cmd = msg[1]
		
		# process the message
		"""

# Configure a custom function for should_run
class GNB_Freesurfer_Processor(Freesurfer_Processor):
    def should_run(self, sess_info):
        try:
            sess_date = datetime.strptime(sess_info['date'], '%Y-%m-%d')
            return ((datetime.today() - sess_date).days < 30)
        except ValueError:
            return False


GNB_freesurfer = GNB_Freesurfer_Processor()

# Set up processors for projects
p = {
    'NewhouseCC': [freesurfer, dti, fmri, vbm],
    'NewhousePL': [freesurfer, dti, fmri],
    'NewhouseBC': [freesurfer, dti, fmri],
    'NewhouseMDDHx': [freesurfer, dti, fmri, vbm],
    'TAYLOR': [freesurfer, dti, fmri],
    'GNB_V': [freesurfer, dti, fmri],
    'GNB': [GNB_freesurfer],
    'R21Perfusion': [freesurfer, dti, fmri, vbm]
}

# Configure launcher with specific queue limit and job dir
myLauncher = Launcher(p,
                      queue_limit=1000,
                      root_job_dir='/gpfs21/scratch/' + os.getlogin() + '/tmp')
RegionScreen.setConfig(Config)

Finder.setLogger(EntityLoggerProxy)
Finder.setConfig(Config)
Finder.setTransform(Transform)

MultiResultProxy.setEntitySearcher(Searcher)

Formatter.setTool(Tool)
Formatter.setConfig(Config)

EntityTransform.setConfig(Config)

Canvas.setDefaultDrawingStrategy(SegmentDrawingStrategy)

Launcher.setLogger(EntityLoggerProxy)


## Boot

logger = EntityLoggerProxy()
logger.info("[SikuliFramework] Booting.. SikuliVersion=%s" % Env.getSikuliVersion())

# Works on all platforms
slash = "\\" if Env.getOS() == OS.WINDOWS else "/"

# Add image libraries (searched in order)
addImagePath(Config.imageBaseline + slash + "os" + slash + str(Env.getOS()).lower() + slash + str(Env.getOSVersion(True)).lower() + slash + Config.language )
addImagePath(Config.imageBaseline + slash + "os" + slash + str(Env.getOS()).lower() + slash + str(Env.getOSVersion(True)).lower())

addImagePath(Config.imageBaseline + slash + "os" + slash + str(Env.getOS()).lower() + slash + Config.language )
Exemple #45
0
                ).text
                author_id = ''.join(
                    re.findall(
                        re.compile('id=(\d+)'),
                        each.find_element_by_xpath(
                            './div/div[3]/div/div/div/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div/div/div[2]/h5/span/span/a'
                        ).get_attribute('data-hovercard')))
                pic_url = each.find_element_by_xpath(
                    './div/div[3]/div/div/div/div/div/div[2]/div/div/a/div/img'
                ).get_attribute('src')
                time = each.find_element_by_xpath(
                    './div/div[3]/div/div/div/div[2]/div/div[2]/div/div/div/div[2]/div/div/div[2]/div/span[3]/span/a/abbr'
                ).get_attribute('data-utime')
                try:
                    content = each.find_element_by_xpath(
                        './div/div[3]/div/div/div/div[2]/div/div[2]/div[2]/div/div/p'
                    ).text
                except Exception as e:
                    content = 'None'

    def save(self, indexName, typeName, item):
        es.executeES(indexName, typeName, item)


if __name__ == '__main__':
    fb = Launcher('18538728360', 'zyxing,0513')
    es = es_twitter()
    mention_list = fb.get_mention_list()
    mention = Mention()
    mention.get_mention()
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import bootstrap
from config import Config
from log import EntityLoggerProxy
from log.level import TRACE
from maps.calculator import Calculator
from launcher import Launcher

"""
Simple example that validates that the calculator is present on the screen.
Results can be found in the /results directory. 
"""
    
# Change logging level verbosity
EntityLoggerProxy.getLogger().setLevel(TRACE)
Config.setScreenshotLoggingLevel(TRACE)

# Launch the Calculator binary
calculator = Launcher.run('Calculator')

# Validate that the calculator exists on the screen
calculator.validate()
Exemple #47
0
 def __init__(self, username, password):
     self.launcher = Launcher(username, password)
     self.es = Es_fb()
     self.comment_list, self.driver = self.launcher.get_comment_list()
     self.list = []
     self.update_time = int(time.time())