Skip to content

Commit 29ed520

Browse files
committed
changes
1 parent 48196d0 commit 29ed520

File tree

3 files changed

+107
-7
lines changed

3 files changed

+107
-7
lines changed

ProdikaUtility.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# -*- coding: UTF-8 -*-
2+
from __future__ import unicode_literals
3+
import os,sys,subprocess,stat
4+
import xml.dom.minidom
5+
import codecs
6+
from colorama import Fore, Back, Style,init
7+
8+
#init colorama
9+
init()
10+
11+
def GreenPrint(s):
12+
print Fore.GREEN + s + Fore.RESET
13+
14+
def RedPrint(s):
15+
print Fore.RED + s+ Fore.RESET
16+
17+
def MagentaPrint(s):
18+
print Fore.MAGENTA + s+ Fore.RESET
19+
20+
def YellowPrint(s):
21+
print Fore.YELLOW + s+ Fore.RESET
22+
23+
class Prodika(object):
24+
'''Prodika工具箱'''
25+
26+
#规范:变量小写开头,方法大写开头
27+
#方法前面的A_前缀是为了方法自省排序的时候使用
28+
29+
prodikaPath = r'd:\WorkProject\private\lqian\v6.1.1.0_20120724\Prodika'
30+
31+
32+
def _ChangeCoreAppSettingValue(self,v):
33+
'''更改控制显示控件路径的文件节点'''
34+
coreAppConfig = os.path.join(self.prodikaPath,r'config\Core\CoreAppSettings.config')
35+
#更改文件只读属性
36+
os.chmod(coreAppConfig,stat.S_IWRITE)
37+
38+
fileObj = open(coreAppConfig)
39+
x = fileObj.read()
40+
fileObj.close()
41+
42+
doc = xml.dom.minidom.parseString(x)
43+
for node in doc.getElementsByTagName("config"):
44+
if node.parentNode.tagName == 'TranslationManager' and node.getAttribute('key') == 'CACHE_DATA_LOADER_FACTORY':
45+
node.setAttribute('value',v)
46+
47+
fileObj = codecs.open(coreAppConfig,'w','utf-8')
48+
fileObj.write( doc.toxml().replace('<?xml version="1.0" ?>',''))
49+
fileObj.close()
50+
GreenPrint('文件写入成功,正在重启IIS...')
51+
os.system('iisreset')
52+
GreenPrint('Done!')
53+
54+
def A_EnableControlDetailPath(self):
55+
'''显示控件详细路径'''
56+
57+
v = 'Class:Xeno.Prodika.Translation.Loaders.PhantomTranslationCacheDataLoaderFactory,PlatformExtensions'
58+
self._ChangeCoreAppSettingValue(v)
59+
60+
def A_UnEnableControlDetailPath(self):
61+
'''不显示控件详细路径'''
62+
63+
v = 'Class:Xeno.Prodika.Translation.StandardTranslationCacheDataLoaderFactory,CoreAppPlatform'
64+
self._ChangeCoreAppSettingValue(v)
65+
66+
def B_StartRemotingContainer(self):
67+
'''开启Remoting Container'''
68+
69+
rPath = os.path.join(self.prodikaPath,r'Code\Apps\RemotingContainer\bin\RemotingContainer.exe -normal')
70+
GreenPrint('正在启动...')
71+
#subprocess.Popen(args=rPath, shell=False)
72+
os.system(rPath)
73+
74+
p = Prodika()
75+
methods = [i for i in dir(p) if not i.startswith('_') and i[0].isupper()]
76+
print '========================================================='
77+
print '\n请选择需要进行的操作:(按Q退出)\n'
78+
for i in range(len(methods)):
79+
m = methods[i]
80+
print str(i) + '. ' + getattr(p,m).__doc__
81+
print '\n========================================================='
82+
83+
selected = ''
84+
while(selected != 'q'):
85+
YellowPrint('\n请选择序号:')
86+
selected = raw_input()
87+
for i in range(len(methods)):
88+
if selected == str(i):
89+
getattr(p,methods[i])()

SkyDrive.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#coding=gbk
2+
3+
from __future__ import unicode_literals
4+
5+
from skydrive import api_v5 as api
6+
7+
8+
auth = api.SkyDriveAuth(client_id='00000000480D1D0D',client_secret='5QFkuwb3Pfp4y-ZdrW52j0kPJMvDSnaB')
9+
auth.auth_refresh_token = 'abed2ff6-8212-8904-b669-b5e510affdcf'
10+
print auth.auth_get_token()
11+
#print api.SkyDriveAPI(auth).listdir()
12+
#print api.SkyDriveAPI().auth_user_get_url()
13+

TaoBao/TBCoin.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77

88
class TBCoin(object):
99
'''
10-
淘金币模块
11-
12-
使用之前,请确保已经使用TBLogin.py进行登录
10+
淘金币模块
11+
使用之前,请确保已经使用TBLogin.py进行登录
1312
'''
1413

1514
tb = TBLogin()
1615

1716

1817
def getCurrentTBCoin(self):
1918
"""
20-
获得当前登录用户的淘金币数量
21-
22-
返回值:成功则返回金币数量,失败则返回None
19+
获得当前登录用户的淘金币数量
20+
返回值:成功则返回金币数量,失败则返回None
2321
"""
2422

2523
r = re.compile('<strong id="J_Coin">(.*?)</strong>', re.S)
@@ -31,6 +29,6 @@ def getCurrentTBCoin(self):
3129
return int(coin) if coin else None
3230

3331
if __name__ == '__main__':
34-
t = TBLogin('','')
32+
t = TBLogin('[email protected]','autorun123456')
3533
if t.login():
3634
print TBCoin().getCurrentTBCoin()

0 commit comments

Comments
 (0)