Skip to content

Commit 37dfb8e

Browse files
author
Kevin Li
committed
update: python tries
1 parent f912066 commit 37dfb8e

35 files changed

Lines changed: 681 additions & 9 deletions

Logs/daily_logs_centralizing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def scpDailyCrashLogsToLocal(remote, local, productType):
1515

1616
# print 'scp -r %s %s'%(remote, local)
1717
os.chdir(local)
18-
subprocess.Popen('scp -r %s/%s_* ./' %(remote, productType))
18+
subprocess.Popen('scp -r %s/%s_* ./' %(remote, productType.lower()))
1919
# subprocess.Popen('scp -r %s/%s_* ./'%(remote, productType))
2020

2121
safe_print('>>>> Copy done!')
@@ -39,6 +39,7 @@ def getAllCrashLogFolders(pPath, productType):
3939
remoteN1ParentPath = 'k22li@10.233.7.215:~/N/NST_Home/TestResult'
4040
remoteN2ParentPath = 'root@10.233.19.232:/home/nst/TestResult'
4141

42+
remoteN2ParentPath_2 = 'root@10.233.19.232:/home/nst_workstation_2/TestResult'
4243
localParentPath = r'c:/Users/k22li/AoL/nst_logs'
4344
# localParentPath = os.path.join('c:\\', 'Users', 'k22li', 'AoL', 'nst_logs')
4445

@@ -48,7 +49,7 @@ def getAllCrashLogFolders(pPath, productType):
4849
if productType in ['n1', 'N1', '1']:
4950
remotePath = remoteN1ParentPath
5051
else:
51-
remotePath = remoteN2ParentPath
52+
remotePath = remoteN2ParentPath_2
5253
#
5354
# crashLogFolders = getAllCrashLogFolders(remotePath, productType)
5455
# print crashLogFolders
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
__author__ = 'k22li'
2+
3+
import os
4+
import sys
5+
import re
6+
import subprocess
7+
import shutil
8+
9+
def scpDailyCrashLogsToLocal(remote, local, productType):
10+
if not os.path.isdir(local):
11+
try:
12+
os.mkdir(local)
13+
except IOError, e:
14+
safe_print('>>>> You\'ve met some problem when creating the folder: %s'%local)
15+
16+
# print 'scp -r %s %s'%(remote, local)
17+
os.chdir(local)
18+
subprocess.Popen('scp -r %s/%s_* ./' %(remote, productType.lower()))
19+
# subprocess.Popen('scp -r %s/%s_* ./'%(remote, productType))
20+
21+
safe_print('>>>> Copy done!')
22+
23+
def safe_print(comment):
24+
sys.stdout.write(comment)
25+
sys.stdout.flush()
26+
27+
def getAllCrashLogFolders(pPath, productType):
28+
productType = productType.lower()
29+
crashLogFolders = []
30+
if os.path.isdir(pPath):
31+
folderNames = os.listdir(pPath)
32+
33+
crashLogFolders = map(lambda folderName : re.match(re.complie(productType), folderName).group(0), folderNames)
34+
35+
return crashLogFolders
36+
37+
if __name__=='__main__':
38+
39+
remoteN1ParentPath = 'k22li@10.233.7.215:~/N/NST_Home/TestResult'
40+
remoteN2ParentPath = 'root@10.233.19.232:/home/nst/TestResult'
41+
localN2ParentPath = 'k22li@10.233.7.215:~/N/NST_Home/TestResult'
42+
43+
localParentPath = r'c:/Users/k22li/AoL/nst_logs'
44+
# localParentPath = os.path.join('c:\\', 'Users', 'k22li', 'AoL', 'nst_logs')
45+
46+
productType = raw_input( \
47+
'>>>> Kindly let me know the product you want to tracking.\nYour answer (n1|n2) : ')
48+
49+
if productType in ['n1', 'N1', '1']:
50+
remotePath = remoteN1ParentPath
51+
else:
52+
remotePath = localN2ParentPath
53+
#
54+
# crashLogFolders = getAllCrashLogFolders(remotePath, productType)
55+
# print crashLogFolders
56+
#
57+
# for subfolder in crashLogFolders:
58+
# remoteTargetPath = os.path.join(remotePath, subfolder)
59+
scpDailyCrashLogsToLocal(remotePath, localParentPath, productType)
60+

Logs/nst_testplan_generator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
ADVANCED_EXEC_DURATION='60'
1919
MST_EXEC_DURATION = '20'
2020

21-
#BASIC_EXEC_TUPLE = ('addAppointment.py', 'addAppointmentToCalendar.py', 'addCalendarToActivityScreen.py', 'deleteAppointmentInTheCalendar.py', 'bluetoothSetting.py', 'call_fastlane.py', 'callFromMadeList.py', 'callFromMissedList.py', 'callFromPhonebook.py', 'callFromRecvList.py', 'changeWP.py', 'closeMusicPlayer.py', 'dataConn.py', 'listenDownloadedRingTone.py', 'downloadAndSetRingTone.py', 'deleteDownloadRingTone.py', 'downloadImageAndSetWallpaper.py', 'deleteDownloadedImage.py', 'downloadJavaApp.py', 'deleteDownloadedJavaApp.py', 'downloadVideoWithDRM.py', 'deleteDownloadedVideo.py', 'sendMMSWithAudio.py', 'openMMSWithAudio.py', 'sendMMSWithPic.py', 'openMMSWithImage.py', 'sendMMSWithVideo.py', 'openMMSWithVideo.py', 'sendSegSMS.py', 'openAndCloseRadio.py', 'openAndPlaybackDownloadedVideo.py', 'openBrowser.py', 'openDownloadedImage.py', 'deleteDownloadedImage.py', 'openDownloadedVideo.py', 'deleteDownloadedVideo.py', 'openEmail.py', 'openMusicPlayer.py', 'takePicture.py', 'openPicGallery.py', 'deletePicGallery.py', 'recordVideo.py', 'playVideoFromGallery.py', 'deleteVideoGallery.py', 'setAnAlarm.py', 'deleteAllAlarm.py', 'openPreloadGame.py', 'openSMS.py', 'addContact.py', 'deleteContact.py', 'ebuddy.py', 'javagame.py', 'mute_notification.py', 'navigateToLink.py', 'wifi_notification.py', 'playMusic.py', 'playVideoStreamingContentUsingDeviceBrowserAndVideoPlayer.py', 'recvCall.py', 'wifi_search.py', 'createDrafMail.py', 'sendEmail.py', 'createDrafMail.py', 'sendEmailWithAttach.py', 'setWallpaper.py', 'silentProfile.py', 'sms_fastlane.py', 'wlanFromSetting.py', 'data_settings.py')
22-
BASIC_CASES = 'calc.py , callFromPhonebook.py , callFromRecvList.py , callFromMadeList.py , callFromMissedList.py , recvCall.py , addContact.py , deleteContact.py , sendSegSMS.py , openSMS.py , sendMMSWithAudio.py , openMMSWithAudio.py , sendMMSWithVideo.py , openMMSWithVideo.py , sendMMSWithPic.py , openMMSWithImage.py , openBrowser.py , downloadAndSetRingTone.py , deleteDownloadRingTone.py , downloadImageAndSetWallpaper.py , deleteDownloadedImage.py , downloadVideoWithDRM.py , deleteDownloadedVideo.py , downloadJavaApp.py , deleteDownloadedJavaApp.py , listenDownloadedRingTone.py , openDownloadedImage.py , openAndPlaybackDownloadedVideo.py , addAppointmentToCalendar.py , addCalendarToActivityScreen.py , deleteAppointmentInTheCalendar.py , setAnAlarm.py , deleteAllAlarm.py , recordVideo.py , playVideoFromGallery.py , deleteVideoGallery.py , takePicture.py , openPicGallery.py , deletePicGallery.py , call_fastlane.py , sms_fastlane.py , openAndCloseRadio.py , playVideoStreamingContentUsingDeviceBrowserAndVideoPlayer.py , openMusicPlayer.py , playMusic.py , closeMusicPlayer.py , openPreloadGame.py , javagame.py , setWallpaper.py , changeWP.py , ebuddy.py , sendEmail.py , sendEmailWithAttach.py , createDrafMail.py , openEmail.py , bt_settings.py , wifi_settings.py , wifi_search.py , wifi_notification.py , bluetoothSetting.py , data_settings.py , data_notification.py , mute_notification.py , testPoxReferencePhone.py'
21+
#BASIC_EXEC_TUPLE = ('addAppointment.py', 'ddAppointmentToCalendar.py', 'addCalendarToActivityScreen.py', 'deleteAppointmentInTheCalendar.py', 'bluetoothSetting.py', 'call_fastlane.py', 'callFromMadeList.py', 'callFromMissedList.py', 'callFromPhonebook.py', 'callFromRecvList.py', 'changeWP.py', 'closeMusicPlayer.py', 'dataConn.py', 'listenDownloadedRingTone.py', 'downloadAndSetRingTone.py', 'deleteDownloadRingTone.py', 'downloadImageAndSetWallpaper.py', 'deleteDownloadedImage.py', 'downloadJavaApp.py', 'deleteDownloadedJavaApp.py', 'downloadVideoWithDRM.py', 'deleteDownloadedVideo.py', 'sendMMSWithAudio.py', 'openMMSWithAudio.py', 'sendMMSWithPic.py', 'openMMSWithImage.py', 'sendMMSWithVideo.py', 'openMMSWithVideo.py', 'sendSegSMS.py', 'openAndCloseRadio.py', 'openAndPlaybackDownloadedVideo.py', 'openBrowser.py', 'openDownloadedImage.py', 'deleteDownloadedImage.py', 'openDownloadedVideo.py', 'deleteDownloadedVideo.py', 'openEmail.py', 'openMusicPlayer.py', 'takePicture.py', 'openPicGallery.py', 'deletePicGallery.py', 'recordVideo.py', 'playVideoFromGallery.py', 'deleteVideoGallery.py', 'setAnAlarm.py', 'deleteAllAlarm.py', 'openPreloadGame.py', 'openSMS.py', 'addContact.py', 'deleteContact.py', 'ebuddy.py', 'javagame.py', 'mute_notification.py', 'navigateToLink.py', 'wifi_notification.py', 'playMusic.py', 'playVideoStreamingContentUsingDeviceBrowserAndVideoPlayer.py', 'recvCall.py', 'wifi_search.py', 'createDrafMail.py', 'sendEmail.py', 'createDrafMail.py', 'sendEmailWithAttach.py', 'setWallpaper.py', 'silentProfile.py', 'sms_fastlane.py', 'wlanFromSetting.py', 'data_settings.py')
22+
#BASIC_CASES = 'calc.py , callFromPhonebook.py , callFromRecvList.py , callFromMadeList.py , callFromMissedList.py , recvCall.py , addContact.py , deleteContact.py , sendSegSMS.py , openSMS.py , sendMMSWithAudio.py , openMMSWithAudio.py , sendMMSWithVideo.py , openMMSWithVideo.py , sendMMSWithPic.py , openMMSWithImage.py , openBrowser.py , downloadAndSetRingTone.py , deleteDownloadRingTone.py , downloadImageAndSetWallpaper.py , deleteDownloadedImage.py , downloadVideoWithDRM.py , deleteDownloadedVideo.py , downloadJavaApp.py , deleteDownloadedJavaApp.py , listenDownloadedRingTone.py , openDownloadedImage.py , openAndPlaybackDownloadedVideo.py , addAppointmentToCalendar.py , addCalendarToActivityScreen.py , deleteAppointmentInTheCalendar.py , setAnAlarm.py , deleteAllAlarm.py , recordVideo.py , playVideoFromGallery.py , deleteVideoGallery.py , takePicture.py , openPicGallery.py , deletePicGallery.py , call_fastlane.py , sms_fastlane.py , openAndCloseRadio.py , playVideoStreamingContentUsingDeviceBrowserAndVideoPlayer.py , openMusicPlayer.py , playMusic.py , closeMusicPlayer.py , openPreloadGame.py , javagame.py , setWallpaper.py , changeWP.py , ebuddy.py , sendEmail.py , sendEmailWithAttach.py , createDrafMail.py , openEmail.py , bt_settings.py , wifi_settings.py , wifi_search.py , wifi_notification.py , bluetoothSetting.py , data_settings.py , data_notification.py , mute_notification.py , testPoxReferencePhone.py'
23+
BASIC_CASES = 'calc.py,callFromPhonebook.py,callFromRecvList.py,callFromMadeList.py,callFromMissedList.py,recvCall.py,addContact.py,deleteContact.py,sendSegSMS.py,openSMS.py,sendMMSWithAudio.py,openMMSWithAudio.py,sendMMSWithVideo.py,openMMSWithVideo.py,sendMMSWithPic.py,openMMSWithImage.py,openBrowser.py,downloadAndSetRingTone.py,listenDownloadedRingTone.py,deleteDownloadRingTone.py,downloadImageAndSetWallpaper.py,openDownloadedImage.py,deleteDownloadedImage.py,downloadVideoWithDRM.py,openAndPlaybackDownloadedVideo.py,deleteDownloadedVideo.py,downloadJavaApp.py,deleteDownloadedJavaApp.py,addAppointmentToCalendar.py,addCalendarToActivityScreen.py,deleteAppointmentInTheCalendar.py,setAnAlarm.py,deleteAllAlarm.py,recordVideo.py,playVideoFromGallery.py,deleteVideoGallery.py,takePicture.py,openPicGallery.py,deletePicGallery.py,call_fastlane.py,sms_fastlane.py,openAndCloseRadio.py,playVideoStreamingContentUsingDeviceBrowserAndVideoPlayer.py,openMusicPlayer.py,playMusic.py,closeMusicPlayer.py,openPreloadGame.py,javagame.py,setWallpaper.py,changeWP.py,ebuddy.py,sendEmail.py,sendEmailWithAttach.py,createDrafMail.py,openEmail.py,bt_settings.py,wifi_settings.py,wifi_search.py,wifi_notification.py,data_settings.py,data_notification.py,mute_notification.py,bluetoothSetting.py'
2324
BASIC_EXEC_TUPLE = BASIC_CASES.split(' , ')
2425
#USELESS_SCRIPTS = ['BlackScreen.py', 'calc01.py', 'calc2.py', 'rpcCall.py', 'settingsSample.py', 'test_scenario3.py', 'inputTest.py', 'phoneCall_PlayMusic.py', 'testPoxReferencePhone.py', 'listenDownloadedRing.py', 'deleteDownloadedRing.py', 'test.py', 'bt_settings.py', 'wifi_settings.py', 'data_notification.py']
25-
USELESS_SCRIPTS = []
26-
26+
USELESS_SCRIPTS = ['testPoxReferencePhone.py', 'bluetoothSetting.py']
2727
#######################################################################################################################
2828
#Sub-Functions
2929
#######################################################################################################################
@@ -216,7 +216,7 @@ def debuggingLines():
216216
whiteList = []
217217

218218
enableRandomize = raw_input( \
219-
'Do you want to enable the randomize sorting of the Advanced test executions?\nYour answer (yes|no) : ')
219+
'Do you want to enable the randomize sorting of the Advanced test executions?\nYour answer (yes|no) : ')
220220

221221
if enableRandomize.startswith('Y') or enableRandomize.startswith('y'):
222222
enableRandomize = True
@@ -238,4 +238,4 @@ def debuggingLines():
238238
debuggingLines()
239239

240240
# generate the text plan xml file
241-
composeTestPlan(deviceIDs= deviceGroup, caseList=cases, randomizeEnable=enableRandomize, whiteList=whiteList, debug=False)
241+
composeTestPlan(deviceIDs= deviceGroup, caseList=cases, randomizeEnable=enableRandomize, whiteList=whiteList, debug=False)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__author__ = 'k22li'
2+
3+
#import numpy as np
4+
5+
a = [1, 2, 3, 4]
6+
b = [5, 6, 7, 8]
7+
8+
print a*2 # output: [1, 2, 3, 4, 1, 2, 3, 4] scalar operations for lists and element by element basis
9+
10+
print a+b # output: [1, 2, 3, 4, 5, 6, 7, 8]
11+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
__author__ = 'k22li'
2+
3+
from datetime import datetime
4+
5+
# purpose: just want explain that by using of datetime module it's by default be aware of the leap years
6+
7+
a = datetime(2012, 2, 28)
8+
b = datetime(2012, 3, 1)
9+
10+
c = b - a
11+
12+
print c
13+
print c.days
14+
15+
16+
d = datetime(2013, 2, 28)
17+
e = datetime(2013, 3, 1)
18+
19+
f = e-d
20+
21+
print f
22+
print f.days
23+
print f.seconds
24+
print f.min
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
__author__ = 'k22li'
2+
3+
4+
#case 1: floating-point numbers calculations can't accurately represent all base-10 decimals
5+
6+
a = 2.1
7+
b = 4.2
8+
print a+b # which expecting 6.3 as the results, but because of the underlying CPU and the IEEE arithmetic performed by
9+
# its floating-point unit.
10+
# ACTUAL RESULT: 6.30000000000001
11+
print a+b == 6.3 # False as the actual results because of the gaps as mentioned above
12+
13+
14+
# Solutions: importing the Decimal modules for decimal calculations.
15+
from decimal import Decimal
16+
a = Decimal('2.1')
17+
b = Decimal('4.2')
18+
19+
print a+b
20+
21+
print type(a+b)
22+
23+
print (a+b) == Decimal('6.3')
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
__author__ = 'k22li'
2+
#format is a built-in functions from Python
3+
4+
# case 1:
5+
6+
a = 1234.56789
7+
8+
#^ stands for center justified displaying with the 10 digits length
9+
# , stands for displaying of the 'Inclusions of thousands separator
10+
# 2f stands for reserving the 2 digits after the
11+
print format(a, '^10,.2f'), len(str(a))
12+
13+
# < stands for left justified displaying of 10 digits as the outputs
14+
print format(a, '<10,.2f'), len(str(a))
15+
16+
#> stands for right justified displaying of the 10 digits as the outputs
17+
print format(a, '>10,.2f'), len(str(a))
18+
19+
20+
21+
#fractions.Fraction
22+
23+
from fractions import Fraction
24+
25+
print Fraction(5, 4) # 5/4
26+
27+
print Fraction(6, 4) # 3/2
28+
29+
30+
a = Fraction(5, 4)
31+
b = Fraction(7, 16)
32+
33+
print a+b
34+
c = a*b
35+
36+
print 'c.numerator: %s; c.denominator: %s'%(c.numerator, c.denominator)
37+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__author__ = 'k22li'
2+
3+
from dateutil import relatived
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__author__ = 'k22li'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__author__ = 'k22li'
2+
3+
aList = ['a', 'b', 'c', 'a']
4+
5+
aList.remove('a')
6+
7+
print aList
8+
9+
aDict = {'a':1, 'b':2, 'c':3, 'a':6}
10+
11+
aDict.pop('a')
12+
13+
print aDict

0 commit comments

Comments
 (0)