def __person_cardlist(self, url_param, uid): uid = str(uid) if type(url_param) is not types.DictType: if type(url_param) is types.StringType: url_param = tool.url2Dict(url_param) else: return {} cururl_para = tool.url2Dict( "https://api.weibo.cn/2/cardlist?gsid=_2A253UqW1DeRxGeBK61QW8i_EzzuIHXVSSb59rDV6PUJbkdANLRHwkWpNR_4pDT5xGeh3D3L_tq3fphqWEtcPPV_8&wm=3333_2001&i=9b17ad6&b=0&from=107C293010&c=iphone&networktype=wifi&v_p=56&skin=default&v_f=1&s=3c8f3a0a&lang=zh_CN&sflag=1&ua=iPhone9,1__weibo__7.12.2__iphone__os11.1&ft=0&aid=01Av9tn9LLqR5apU_SfKnDUAO9Wacfs76KIEBqPTg2v5UOHNk.&mid=4195012604100383&_status_id=4195012604100383&count=20&luicode=10000001&containerid=1078036004281123&featurecode=10000001&uicode=10000198&fid=1078036004281123&rid=0_0_8_3080955430742652852&fromlog=100016406721847&need_head_cards=0&page=1&lfid=100016406721847&moduleID=pagecard&since_id=4194771415644594_4194791794737655_20180111_-1" ) for param_k, param_v in url_param.items(): cururl_para[param_k] = param_v cururl_para["containerid"] = "107803" + uid cururl_para["fid"] = "107803" + uid url = "https://api.weibo.cn/2/cardlist?" + urllib.urlencode( cururl_para) url_content = tool.getUrlContent(url) sys.sleep(2) cururl_para["containerid"] = "107803" + uid + "_-_mcn" cururl_para["fid"] = "107803" + uid + "_-_mcn" url = "https://api.weibo.cn/2/cardlist?" + urllib.urlencode( cururl_para) url_content = tool.getUrlContent(url) sys.sleep(2) cururl_para["containerid"] = "230283" + uid cururl_para["fid"] = "230283" + uid url = "https://api.weibo.cn/2/cardlist?" + urllib.urlencode( cururl_para) url_content = tool.getUrlContent(url) return url_content
def waiter (ExecutionId): while 1: response = ec2_ssm.describe_automation_executions( Filters = [ { 'Key': 'ExecutionId', 'Values': [ ExecutionId, ] }, ], ) if len(response['AutomationExecutionMetadataList']) != 0: if response['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus'] == 'Success': print ('{0} execution complete'.format(ExecutionId)) break elif response['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus'] == 'Failed': print ('{0} execution failed'.format(ExecutionId)) sys.exit(-1) else: print ('{0} in progress, wait 5 seonds to refresh status'.format(ExecutionId)) sys.sleep(5) else: print ('no record found, exit') sys.exit(-1)
def autonomous(): #autonomous_class.goto() print("Checkpoint 1: You are a failure") motor_arm.rotate_to(-390, vex.RotationUnits.DEG, 20, vex.VelocityUnits.PCT) print("Checkpoint 2: What is wrong with you!!!") driveTrain.drive_for(vex.DirectionType.FWD, ToCm(1, "FEET"), vex.DistanceUnits.CM, 20, vex.VelocityUnits.PCT) print("Checkpoint 3: What is wrong with you!!!") motor_arm.stop(vex.BrakeType.HOLD) driveTrain.turn_for(vex.TurnType.RIGHT, 100.5, vex.RotationUnits.DEG, 20, vex.VelocityUnits.PCT) driveTrain.drive_for(vex.DirectionType.FWD, ToCm(5.5, "FEET"), vex.DistanceUnits.CM, 40, vex.VelocityUnits.PCT) sys.sleep(1) driveTrain.drive_for(vex.DirectionType.REV, ToCm(3.35, "FEET"), vex.DistanceUnits.CM, 20, vex.VelocityUnits.PCT) driveTrain.turn_for(vex.TurnType.RIGHT, 102, vex.RotationUnits.DEG, 20, vex.VelocityUnits.PCT) driveTrain.drive_for(vex.DirectionType.REV, ToCm(2, "FEET"), vex.DistanceUnits.CM, 50, vex.VelocityUnits.PCT) motor_arm.rotate_to(0, vex.RotationUnits.DEG, 20, vex.VelocityUnits.PCT) driveTrain.drive_for(vex.DirectionType.REV, ToCm(10, "INCHES"), vex.DistanceUnits.CM, 50, vex.VelocityUnits.PCT) motor_arm.rotate_to(-200, vex.RotationUnits.DEG, 20, vex.VelocityUnits.PCT) driveTrain.drive_for(vex.DirectionType.REV, ToCm(3, "INCHES"), vex.DistanceUnits.CM, 40, vex.VelocityUnits.PCT)
def run(self): # This is the supported browser list and can be added to. browsers = [ '/opt/google/chome/chrome', '/usr/bin/firefox', '/usr/bin/opera'] for b in browsers: if self.browser_exists(self._browser_) and self.count == 0: _browser_ = re.match("(\/\w+)(.*\/)(\w+)",self._browser_).group(3) break self.count += 1 if self.count > len(b): logger.log("ERROR", "Only the following browsers are supported: Chrome, Opera, and Firefox.") elif self.browser_exists(b): _browser_ = re.match("(\/\w+)(.*\/)(\w+)",b).group(3) break if _browser_ == 'chrome': call([self._browser_, "--user-data-dir=" + str(fileOpts.root_directory()), "--no-sandbox", "" + self._website_ + "?Email=" + self._email_]) elif _browser_ == 'firefox': call([self._browser_,"--new-window", "" + self._website_ + "?Email=" + self._email_ + "\""]) #elif _browser_ == 'opera': else: logger.log("WARNING", "\n\nBrowser not " + "found and location functionality will not work.\n\n") sys.sleep(2)
def sendTelnet(): while (1) : ssh_newkey = 'Are you sure you want to continue connecting' p=pexpect.spawn('telnet 10.0.0.2') i=p.expect([ssh_newkey,'password:'******':','#']) if i==3: print "Telnet Requesting uname" p.sendline('root') p.expect([ssh_newkey,'password:'******':','#']) if i==0: p.sendline('yes') i=p.expect([ssh_newkey,'password:'******'ls') p.expect('#') elif i==2: print "Sorry!.. Connection timedout.. Not able to connect to the remote host" pass print p.before sys.sleep(1)
def input(): try: inputfile = sys.argv[1] ifile = open(inputfile, 'r') while 1: line = ifile.readline() if not line: break if not line.startswith('#'): line = line.rstrip() exec(line) ifile.close() # set default value for TiStPos if there is no input provided try: TiStPos except NameError: TiStPos = [] for i in TiStPos: if i < 0 or i > NTiSt: print 'Check your input parameters for TiStPos!' sys.sleep(3) except: print 'Usage:', sys.argv[0], 'inputfile', '>', 'outputfile' sys.exit(1) return Npart, float(Lbox), float(mass), float(eps), float(sigma), float( T), float(dTiSt), NTiSt, TiStPos, float(Rcut), float(Rl)
def autonomous(): turnFlywheelOn(False) #Grab first ball from under cap turnIntakeOn() robot.moveBy(100) robot.moveBy(-95) robot.rotateTo(87) #fire top two flags fireABall() robot.moveBy(65) fireABall() turnIntakeOff() moveArmUp(0.5, 50, False) #score lower flag twoBar.stop(vex.BrakeType.HOLD) robot.rotateTo(75) robot.moveBy(20) robot.moveBy(-20) twoBar.stop(vex.BrakeType.COAST) robot.rotateTo(90) #score cap robot.moveBy(-30) robot.rotateTo(5) robot.moveBy(27) sys.sleep(0.5) moveArmUp(0.25, 100, False) moveArmDown(0.25, 100)
def test_pressing_led(): times = 0 while True: if touch_led.pressing(): # True/False times += 1 print("Ui da! Cham vao tui " + str(times) + " lan roi nha!") sys.sleep(0.1)
def move_backward(time): # student code start rone.motor_set_pwm('l', -MOTOR_PWM) rone.motor_set_pwm('r', -MOTOR_PWM) sys.sleep(time) rone.motor_brake('l') rone.motor_brake('r')
def alchemy(hero, npc): i = 0 while i != '3': sys.stdout.write("\x1b[2J\x1b[H") print("{}: {}".format(npc.i.name, npc.i.welcome)) print(" 1. Fuse a weapon.\n 2. Look up a formula.\n 3. Leave") i = read_key() if i == '1' or i == '2': sys.stdout.write("\x1b[2J\x1b[H") if i == '1': p = potential(hero) if len(hero.bag) + len(hero.convoy) == 0: print("You don't even have anything!") sys.sleep(1) elif len(p) == 0: print("No potential matches!") sys.sleep(1) else: fusion(hero, p) elif i == '2': search() elif i == '3': print("Come again!") time.sleep(1) break else: continue
def drivercontrol(): # left cant # right vertical fwd/rev, right horizontal turn while True: controller1.screen.print_(torque()) c1a1 = controller1.axis1.position() # right horizontal c1a2 = controller1.axis2.position() # right vertical # c1a3 = controller1.axis3.position() # left vertical c1a4 = controller1.axis4.position() # left horizontal c2a2 = controller2.axis2.position() flipper.spin(vex.DirectionType.FWD, c2a2, vex.VelocityUnits.PCT) # the left joystick controls the swerve. There is no rotation done via this joystick. swerve_pos = swerve.rotation(vex.RotationUnits.REV) * 2 * math.pi / 3. if controller1.buttonX.pressing(): vision_control() else: base(c1a2 + 0.6 * c1a1 * math.sin(swerve_pos + (math.pi / 4)), c1a2 + 0.6 * c1a1 * math.sin(swerve_pos + (3 * math.pi / 4)), c1a2 + 0.6 * c1a1 * math.sin(swerve_pos + (5 * math.pi / 4)), c1a2 + 0.6 * c1a1 * math.sin(swerve_pos + (7 * math.pi / 4))) cant_control(0.6 * math.pi * (c1a4 / 100)) swerve.spin(vex.DirectionType.FWD, swervePID.apply(swerve.rotation(vex.RotationUnits.REV)), vex.VelocityUnits.PCT) intake.spin(vex.DirectionType.FWD, runIntake, vex.VelocityUnits.PCT) catapult_control() sys.sleep(0.02)
def sendTelnet(): while 1: ssh_newkey = "Are you sure you want to continue connecting" p = pexpect.spawn("telnet 10.0.0.2") i = p.expect([ssh_newkey, "password:"******":", "#"]) if i == 3: print "Telnet Requesting uname" p.sendline("root") p.expect([ssh_newkey, "password:"******":", "#"]) if i == 0: p.sendline("yes") i = p.expect([ssh_newkey, "password:"******"Mahendra") p.expect(pexpect.EOF) if i == 4: print "Logged in to the remote host" p.sendline("ls") p.expect("#") elif i == 2: print "Sorry!.. Connection timedout.. Not able to connect to the remote host" pass print p.before sys.sleep(1)
def turn_right(self): self.direction.x = 0 self.direction.y = 1 # Motor turning self.left_wheels.run(80) self.right_wheels.run(30) sys.sleep(1)
def driver(): sys.sleep(0.2) while True: DriverSwitch() ballController() driveControl() flyWheelControl() flip()
def moveBackwards(time, power): #time measured in milliseconds, power measured in 0-100 percentage newPower = math.fabs(power) leftOne.spin(vex.DirectionType.REV, newPower, vex.VelocityUnits.PCT) leftTwo.spin(vex.DirectionType.REV, newPower, vex.VelocityUnits.PCT) rightOne.spin(vex.DirectionType.REV, newPower, vex.VelocityUnits.PCT) rightTwo.spin(vex.DirectionType.REV, newPower, vex.VelocityUnits.PCT) sys.sleep(time)
def followWall(): findWall() #turn away from wall and move forward turnRight(15) sys.sleep(2) goForward(25) sys.sleep(2) stop()
def get_remote_hostname(): while(True): sys.sleep(10) for root, subdirs, files in os.walk(e_dir): LStr = files.split("FILEO_Meta") if len(LStr) == 2: e_hostname = LStr[1] if e_hostname != hostname: return e_hostname
def main(): dic = translator.Translator() words = get_words() for word in words: dic.find(word,net=True) dic.print_interprets() dic.dump() if dic.interprets_from_file: sys.sleep(3)
def move_forward(time): # student code start if time < 0: rone.motor_set_pwm('r', 0 - MOTOR_PWM) rone.motor_set_pwm('l', 0 - MOTOR_PWM) else: rone.motor_set_pwm('r', MOTOR_PWM) rone.motor_set_pwm('l', MOTOR_PWM) sys.sleep(abs(time))
def disabledMode(): while True: left_motor.off() right_motor.off() scooper_motor.off() print( "Disabled mode flag thrown, all motors disabled. Please restart the robot to continue." ) sys.sleep(5)
def square_motion(): # wait for 2 seconds to let you unplug the robot... sys.sleep(2000) for i in range(1, 5): # student code start move_forward(1500) move_rotate_right(650) # student code end move_stop(100)
def main(self): while True: self.left_wheels.run(self.TOTAL_POWER) self.right_wheels.run(self.TOTAL_POWER) if self.bump_sensor.is_on(): self.back_and_turn() sys.sleep(1)
def random_move(self): while True: left_val = random.randint(-30, 30) right_val = random.randint(-30, 30) self.left_wheels.run(left_val) self.right_wheels.run(right_val) sys.sleep(1.5) if not (self.left_line_tracker.line_tracker_percent() < 69 and self.right_line_tracker.line_tracker_percent() < 69): break
def setup_up_motor(corr): um.run(30) while ub.is_pressed(): sys.sleep(1) while not ub.is_pressed(): pass um.run_until(30, corr) sys.sleep(0.3) um.reset_position() um.off()
def main(): global src_mac_address src_mac_address = sys.argv[1] assert src_mac_address is not None send_trigger_lsa() sys.sleep(SEND_INTERVAL) send_disguised_lsa()
def back_and_turn(self): # Back self.left_wheels.run(-self.TOTAL_POWER) self.right_wheels.run(-self.TOTAL_POWER) sys.sleep(3) # Turn right self.left_wheels.run(self.TOTAL_POWER) self.right_wheels.run(self.TOTAL_POWER / 2) sys.sleep(2)
def FTL_remote(): buttons = check_buttons() if buttons != '': leds.set_pattern('r', 'blink_fast', LED_BRIGHTNESS) rone.radio_send_message(buttons) else: leds.set_pattern('r', 'circle', LED_BRIGHTNESS) #sleep for a bit to avoid continuous radio transmission sys.sleep(REMOTE_XMIT_DELAY)
def check_button(color, count, button_old): button = rone.button_get_value(color) # look for a rising edge on the button press if (button == 1) and (button_old == 0): if count == 5: count = 0 else: count = count + 1 #the button was just pressed. wait a bit for debounce sys.sleep(3) return (count, button)
def flyWheelControl(): global on if DRC_Controler.buttonX.pressing(): on = on * -1 sys.sleep(0.3) if on == -1: flywheel_.spin(vex.DirectionType.FWD, 100, vex.VelocityUnits.PCT) flywheel2.spin(vex.DirectionType.FWD, 100, vex.VelocityUnits.PCT) else: flywheel_.stop(vex.BrakeType.COAST) flywheel2.stop(vex.BrakeType.COAST)
def on_message(client, userdata, message): print("message received ", str(message.payload.decode("utf-8"))) print("message topic=", message.topic) turnOnLedMatrix() sys.sleep(1) turnOffLedMatrix() #send confirmation to server print("Send that client has flash correctly", "server/data") client.publish("server/data", "P1 Done")
def check_button(color, count, button_old): button = rone.button_get_value(color) # look for a rising edge on the button press if (button == 1) and (button_old == 0): if count == 5: count = 0 else: count = count + 1 # the button was just pressed. wait a bit for debounce sys.sleep(3) return (count, button)
def __init__(self): # Globals self.TOTAL_POWER = 30 self.left_wheels = vex.Motor(10) self.right_wheels = vex.Motor(1) self.bump_sensor = vex.DigitalInput(1) self.right_line_tracker = vex.LineTracker(1) self.left_line_tracker = vex.LineTracker(2) self.serial = vex.Serial(1, 9600) self.serial.write("begin") sys.sleep(2)
def main(): global production transact = True if(len(sys.argv) == 2): code = sys.argv[1] production = True main_user = set_user(code) if main_user: dsn_tns = cx_Oracle.makedsn(server, port, SID) connection = None try: connection = cx_Oracle.connect(main_user.username, main_user.password, dsn_tns) try: cursor = connection.cursor() if transact: idReserva2 = 81 idCliente2 = 578 idFuncion1 = 67 idS1 = 13 idS2 = 14 sys.sleep(20) make_transaction(cursor, idReserva2, idCliente2 , idFuncion1, idS1, idS2) # MODIFICAR ESTO sys.sleep(20) print 'Deadlock' else: query = "SELECT * FROM reservas" params = [] if params == []: cursor.execute(query) else: cursor.execute(query, params) result_set = [i for i in cursor.fetchall()] if result_set == []: print 'Empty relation' else: print 'Result' for i in result_set: print i except Exception: print 'Deadlock' finally: cursor.close() finally: if connection is not None: if production: connection.commit() connection.close() else: print 'Wrong code.' else: print 'Wrong usage.'
def bump_avoid(): print "bump_avoid()" sys.sleep(1000) while True: # student code start if (bump_left_get_value()): move_forward(-500) move_rotate_right(800) elif (bump_front_get_value() or bump_right_get_value()): move_forward(-500) move_rotate_left(800) else: move_forward(500)
def moveArmUp(time, power, heightAllowed): #time measured in milliseconds, power measured in 0-100 percentage newPower = math.fabs(power) if heightAllowed == True: twoBar.spin(vex.DirectionType.REV, newPower, vex.VelocityUnits.PCT) sys.sleep(time) else: if math.fabs(twoBar.rotation(vex.RotationUnits.DEG)) > 240: twoBar.stop(vex.BrakeType.HOLD) else: twoBar.spin(vex.DirectionType.REV, newPower, vex.VelocityUnits.PCT) sys.sleep(time)
def flock_demo(): mode = MODE_IDLE beh.init(0.22, 40, 0.5, 0.1) buttons = hba.wait_for_button() if 'r' in buttons: mode = MODE_REMOTE elif 'g' in buttons: mode = MODE_FLOCK # Now that you know your mode, run the main loop while True: # run the system updates new_nbrs = beh.update() beh_out = beh.BEH_INACTIVE if mode == MODE_REMOTE: buttons = hba.check_buttons() if buttons != '': leds.set_pattern('r','blink_fast',LED_BRIGHTNESS) rone.radio_send_message(buttons) else: leds.set_pattern('r','circle',LED_BRIGHTNESS) #sleep for a bit to avoid continuous radio transmission sys.sleep(REMOTE_XMIT_DELAY) elif mode == MODE_FLOCK: bump_beh_out = beh.bump_beh(FTL_TV) receive_beh_out = receive_beh() flock_beh_out = flock_beh() # if beh.get_active(bump_beh_out): # tv = beh.get_tv(bump_beh_out) # rv = beh.get_rv(bump_beh_out) # else: # tv = beh.get_tv(receive_beh_out) + beh.get_tv(flock_beh_out) # rv = beh.get_rv(receive_beh_out) + beh.get_rv(flock_beh_out) flock_beh_out = beh.sum(flock_beh_out, receive_beh_out) beh_out = beh.subsume([flock_beh_out, bump_beh_out]) # set the beh velocities beh.motion_set(beh_out) #set the HBA message hba.set_msg(0, 0, 0)
def commit2Base(self): if self.noWrite: print "Dont write anything to Base" return self.__ab.deleteAdresses(self.toDelete) #self.toDelete = [] i=0 l = self.__djs.size() for addr in self.__djs.parents.keys(): try: self.__ab.writeEntity(addr, self.__djs.parents[addr]) except psycopg2.InternalError: import sys sys.sleep(100) self.__ab.writeEntity(addr, self.__djs.parents[addr]) if i%100 == 0: print 'Writing entities to base. %d of %d done' % (i,l) i+=1 self.__ab.commit()
# This file was *autogenerated* from the file /Users/Olive/Documents/dev/bbdl/cat_model/sohn_data/points_to_volume.sage. from sage.all_cmdline import * # import sage library _sage_const_1 = Integer(1); _sage_const_0 = Integer(0); _sage_const_10 = Integer(10) import csv import sys # filepath = sys.argv[1] # a = csv.reader(open(filepath)) poly_3d_space = Polyhedron(vertices = [ [_sage_const_1 ,_sage_const_0 ,_sage_const_0 ], [_sage_const_0 ,_sage_const_1 ,_sage_const_0 ], [_sage_const_0 ,_sage_const_1 ,_sage_const_0 ]]) vol = poly_3d_space.volume() print(vol) sys.sleep(_sage_const_10 )
# VEX IQ Python-Project import sys import vexiq #region config motor_1 = vexiq.Motor(1) color_2 = vexiq.ColorSensor(2) # hue #endregion config red = (48,40,44,128) blue = (11,27,130,137) color_2.led_on() print("reading") sys.sleep(3) initial = color_2.raw_color() print("initial:", initial) def close(color): measurement = color_2.raw_color() thresholds = (20,25,50,25) for i in range(4): diff = abs(color[i] - measurement[i]) if diff > thresholds[i]: #print(measurement, diff, thresholds[i]) #sys.sleep(1) return False print("hit!", measurement) return True print("watching...") while True:
def main (): while True: #command = raw_input('Enter your command. ie. "send msg to A,B,C", "delete key", "get key Model", "insert key value model", "update key value model", "show-all", "search key", "delay T"\n' ) try: cmd_QueueLock.acquire() cmd = cmd_Queue.get() cmd_QueueLock.release() except: sys.sleep(1) continue #print cmd # Parse command line from Queue cmd_l = cmd.split() if cmd_l[0] == 'send': msg = "" i = 1 while i < len(cmd_l): if(cmd_l[i+1] == 'to'): msg +=cmd_l[i] i+=1 break else: msg += cmd_l[i] + ' ' i+=1 t1 = threading.Thread(target = serverNode.multisend, args = (msg,cmd_l[i+1])) t1.start() t1.join() # elif cmd == 'show-all': # serverNode.showAll() elif cmd_l[0] == 'delay': delayTime = float(cmd_l[1]) sleep(delayTime) else: M = -1 if cmd_l[0] == 'get' or cmd_l[0] == 'insert' or cmd_l[0] == 'update': if cmd_l[0] == 'get': try: M = int(cmd_l[2]) except IndexError,ValueError: print 'Error, input your command again' continue # Send the command only to self #serverNode.multisend(cmd,serverNode.name) else: try: M = int(cmd_l[3]) except: print 'Error, input your command again' continue if M !=model: print('Inconsistency of model, try again') continue # Send to command if serverNode.model == 2: serverNode.timeStamp +=1 data_s = (cmd,serverNode.name) inboxLock.acquire() if serverNode.model == 1: serverNode.inbox.put(data_s,realTime()) elif serverNode.model == 2: serverNode.inbox.put(data_s,serverNode.timeStamp) inboxLock.release() if cmd_l[0] !='get' and cmd_l[0] !='show-all': serverNode.multisend(cmd,otherServer(serverNode.name))
def resCopyToOnline(): #获取在线资源目录中,需要将差异文件放入其中的目录 localDir = os.path.abspath(os.path.dirname(__file__)) scriptMd5 = cmd("if [ -f /app/opbin/workspace/get_update_dir.py ];then md5sum /app/opbin/workspace/get_update_dir.py |awk '{print $1}';fi") localScriptMd5 = common.calMd5(localDir + "/get_update_dir.py") if scriptMd5 != localScriptMd5: sshobj.put(localDir + "/get_update_dir.py",remote_path="/app/opbin/workspace/") #如果为appstore64,首先检查目标版本中是否存在main.lua if updateType == "appstore64": cmd("test -f %s/%s/main.lua"%(onlineTestDir,version)) #if hd: # res_64_dir = cmd("if [ -d %s/%s/res_64 ];then echo 1;else echo 0;fi"%(onlineTestDir,version)) # hd_res_64_dir = cmd("if [ -d %s/%s/hd_res_64 ];then echo 1;else echo 0;fi"%(onlineTestDir,version)) # if res_64_dir.strip() != "1" and hd_res_64_dir.strip() != "1": # print "%s64位目录不存在!"%version # sys.exit(1) #将测试环境中最新的版本资源目录复制到线上环境 cmd("cp -r %s/%s %s/"%(onlineTestDir,version,onlineDir)) #复制最新版本到各版本的差异包到线上 if zipMode: oldDirs = json.loads(cmd("python /app/opbin/workspace/get_update_dir.py '%s' '%s' '%s' '%s' '%s'"%(onlineDir,startVersion,version,updateType,hd))) if not oldDirs["result"]: raise Exception(oldDirs["msg"]) oldDirsList = oldDirs["dir"] for dir in oldDirsList: if dir == version: print "%s 版本跟需要更新的版本一致,不需要差异包"%dir sys.stdout.flush() continue print "开始处理%s的差异包..."%dir sys.stdout.flush() if hd: for t in ["res","hd_res","res_64","hd_res_64"]: dirCheck = cmd("if [ -d %s/%s/%s ];then echo 1;else echo 0;fi"%(onlineDir,dir,t)) if dirCheck.strip() == "1": cmd("cp %s/%s/%s/%s.zip %s/%s/%s/"%(onlineTestDir,dir,t,version,onlineDir,dir,t)) cmd("cp %s/%s/%s/%s.lua %s/%s/%s/"%(onlineTestDir,dir,t,version,onlineDir,dir,t)) cmd("if [ -f %s/%s/%s/index.lua ];then cp %s/%s/%s/index.lua %s/%s/%s/;fi"%(onlineTestDir,dir,t,onlineTestDir,dir,t,onlineDir,dir,t)) else: print "%s/%s/%s 不存在"%(onlineDir,dir,t) sys.stdout.flush() else: cmd("cp -r %s/%s/%s.zip %s/%s/"%(onlineTestDir,dir,version,onlineDir,dir)) cmd("cp -r %s/%s/%s.lua %s/%s/"%(onlineTestDir,dir,version,onlineDir,dir)) cmd("if [ -f %s/%s/index.lua ];then cp %s/%s/index.lua %s/%s/;fi"%(onlineTestDir,dir,onlineTestDir,dir,onlineDir,dir)) #等待30秒钟同步资源目录 print "等待60秒钟同步资源目录..." sys.sleep(60) print "开始更新version.lua文件..." #将version.lua文件更新到线上 if updateType in ["appstore64"] : cmd("cp %s/appstore64/version.lua %s/appstore64/"%(onlineTestDir,onlineDir)) #手游debug模式开关,线上一定置为0 cmd("grep 'sys_version.debug' %s/appstore64/version.lua;if [ $? -eq 0 ];then sed -i '/sys_version.debug/s/1/0/g' %s/appstore64/version.lua;fi"%(onlineDir,onlineDir)) if updateType in ["appstore","all"]: cmd("cp %s/appstore/version.lua %s/appstore/"%(onlineTestDir,onlineDir)) #手游debug模式开关,线上一定置为0 cmd("grep 'sys_version.debug' %s/appstore/version.lua;if [ $? -eq 0 ];then sed -i '/sys_version.debug/s/1/0/g' %s/appstore/version.lua;fi"%(onlineDir,onlineDir)) if updateType in ["jailbreak","all"]: cmd("cp %s/jailbreak/version.lua %s/jailbreak/"%(onlineTestDir,onlineDir)) cmd("grep 'sys_version.debug' %s/jailbreak/version.lua;if [ $? -eq 0 ];then sed -i '/sys_version.debug/s/1/0/g' %s/jailbreak/version.lua;fi"%(onlineDir,onlineDir)) cmd("if [ -f %s/version.lua ];then cp %s/jailbreak/version.lua %s/version.lua;fi"%(onlineDir,onlineDir,onlineDir))