-
Notifications
You must be signed in to change notification settings - Fork 0
/
Upload.py
56 lines (46 loc) · 1.63 KB
/
Upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'''
Created on 2011-7-19
@author: zheng
'''
import smbc
import os
import Constant
from ftplib import FTP
from Utils import myprint
ctx = smbc.Context ()
def upload( p ):
pre_path = Constant.smb_addr_base_path + p.name + '/'
if ( p.build_method == Constant.build_nightly or p.build_method == Constant.build_verify):
uploadSamba( p, pre_path + "Nightly_Build/" + p.latestCommit + '/')
elif ( p.build_method == Constant.build_release ):
#upload both release folder and nightly folder
uploadSamba( p, pre_path + "Nightly_Build/" + p.latestCommit + '/' )
uploadSamba( p, pre_path + "Release_Build/" + p.latestCommit + '/' )
def uploadSamba ( p , folder_path):
#smb://192.168.10.44/root_home/CableBay/Nightly_build/15555/CableBay.apk'
p.smb_addr = folder_path + p.name + '.apk'
ctx.mkdir( folder_path, 755 )
remote_file = ctx.open (p.smb_addr, os.O_CREAT | os.O_WRONLY)
local_file = open(p.workspace_path + "bin/" + p.name + '.apk')
remote_file.write(local_file.read())
myprint ( 'upload '+ p.smb_addr + '...' )
def getPrevCommit ( p ):
# ctx.
pass
'''
def uploadFTP( p):
print 'upload ftp'
ftp = FTP(Constant.ftp_addr)
ftp.login('cablebay', 'smi0801bew')
print "login success"
if(p.build_style=="nightly"):
p.ftp_path=Constant.ftp_path + "Nightly_Build/"
elif(p.build_style=="normal"):
p.ftp_path=Constant.ftp_path
ftp.mkd(p.ftp_path + p.folder_name)
ftp.cwd(p.ftp_path + p.folder_name)
print self.local_file_name
f = open(self.local_file_name, 'rb')
ftp.storbinary('STOR ' + p.apk_file_name, f)
ftp.retrlines('LIST')
'''