#!/usr/bin/python3
# -*- coding:utf-8 -*- # 保证源程序可以输入汉字
print bool([]) # 任何为零的数字或空集(空列表、空元组和空字典等)均为False
radius = input(u"输入半径: ");
radius_float = float(radius);
area=radius_float**2*3.1415926; # **是平方运算,pow()也可以执行平方运算
print u'面积:%f'%(area)
# coding:utf-8
import os
import re
import shutil
from subprocess import Popen, PIPE
safe_imgs_path = os.path.dirname(__file__)
destination_path = safe_imgs_path.split('GlobalRobot')[0] + 'GlobalApp'
proj_path = destination_path + '/GlobalApp.xcodeproj/project.pbxproj'
def getBundleId():
pattern = 'PRODUCT_BUNDLE_IDENTIFIER = (.*);'
bundle_id = None
with open(proj_path) as f:
s = ''.join(f.readlines())
res = re.findall(pattern, s)
if len(res):
bundle_id = res[0]
f.close()
return bundle_id
def handle_safeImage():
bundle_id = getBundleId()
if bundle_id:
cmd = 'cp {img_path}/{img_name}.jpg {des_path}/{des_name}.jpg'.format(img_path=safe_imgs_path, img_name=bundle_id,
des_path=destination_path,
des_name='yw_1222_07e8')
Popen(cmd, shell=True)
def change_robotCode():
bundle_id = getBundleId();
normal_name='a1myR6pZui3';
test_name='a1wYaPBqf6g';
print bundle_id;
root_path=safe_imgs_path.split('GlobalRobot')[0];
logidPath = root_path + 'GlobalRobot/GLBRobot/GLBConfig/GLBRobotConfig.bundle/GLBRobotLogicIdMap.json'
router_path = root_path + 'GlobalRobot/GLBRobot/GLBConfig/GLBRobotConfig.bundle/GLBRobotRouteTable.json'
if bundle_id == 'com.eco.global.app':
changeDX5ClassName(logidPath,normal_name,test_name)
changeDX5ClassName(router_path,normal_name,test_name)
elif bundle_id =='com.vivien.demo':
changeDX5ClassName(logidPath,test_name,normal_name)
changeDX5ClassName(router_path, test_name, normal_name)
return;
def changeDX5ClassName(fileName,toName="a1myR6pZui3",from_name='a1wYaPBqf6g'):
print 'toName'+toName+' ,fromName:'+from_name ;
file_path = fileName;
backup_path = file_path + '.bak'
if not os.path.exists(backup_path):
shutil.copy2(file_path, backup_path)
with open(file_path, mode='r') as fr, open(backup_path, mode='w') as fw:
for line in fr:
re_sub_list = re.sub(from_name, toName, line) # 这里用re.sub进行替换后放入 re_sub_list中
print('re_sub_list'+re_sub_list);
fw.writelines(re_sub_list) # 将列表中的每一行进行写入。writelines是将序列对象中的每一行进行写入。
os.remove(file_path);
os.rename(backup_path, file_path);
if __name__ == '__main__':
print "==============================开始替换安全图片=============================="
handle_safeImage()
print "==============================完成替换安全图片=============================="
print "==============================开始更换DX5 Class=============================="
change_robotCode()
print "==============================完成更换DX5 Class=============================="