Upload 'ns' to plugins dir (create if not exists) #4695

This commit is contained in:
Nick Bolton 2015-05-25 16:05:16 +01:00
parent e4959a7661
commit 91d05c29db
2 changed files with 20 additions and 11 deletions

View File

@ -1343,12 +1343,6 @@ class InternalCommands:
return major + '.' + minor + '.' + rev return major + '.' + minor + '.' + rev
def ftpUpload(self, ftp, source, target):
print "Uploading '%s' as '%s' to FTP server '%s'..." % (
source, target, ftp.host)
ftp.run(source, target)
print 'Done'
def distftp(self, type, ftp): def distftp(self, type, ftp):
if not type: if not type:
raise Exception('Platform type not specified.') raise Exception('Platform type not specified.')
@ -1359,13 +1353,13 @@ class InternalCommands:
packageSource = binDir + '/' + self.dist_name(type) packageSource = binDir + '/' + self.dist_name(type)
packageTarget = self.dist_name_rev(type) packageTarget = self.dist_name_rev(type)
self.ftpUpload(ftp, packageSource, packageTarget) ftp.upload(packageSource, packageTarget)
if (type != 'src'): if (type != 'src'):
pluginsDir = binDir + '/plugins' pluginsDir = binDir + '/plugins'
nsPluginSource = self.findLibraryFile(type, pluginsDir, 'ns') nsPluginSource = self.findLibraryFile(type, pluginsDir, 'ns')
nsPluginTarget = self.getLibraryDistFilename(type, pluginsDir, 'ns') nsPluginTarget = self.getLibraryDistFilename(type, pluginsDir, 'ns')
self.ftpUpload(ftp, nsPluginSource, nsPluginTarget) ftp.upload(nsPluginSource, nsPluginTarget, "plugins")
def getLibraryDistFilename(self, type, dir, name): def getLibraryDistFilename(self, type, dir, name):
(platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type) (platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type)

View File

@ -23,13 +23,28 @@ class FtpUploader:
self.password = password self.password = password
self.dir = dir self.dir = dir
def run(self, src, dest, replace=False): def upload(self, src, dest, subDir=None):
print "Connecting to '%s'" % self.host
ftp = FTP(self.host, self.user, self.password) ftp = FTP(self.host, self.user, self.password)
ftp.cwd(self.dir)
self.changeDir(ftp, self.dir)
if subDir:
self.changeDir(ftp, subDir)
print "Uploading '%s' as '%s'" % (src, dest)
f = open(src, 'rb') f = open(src, 'rb')
ftp.storbinary('STOR ' + dest, f) ftp.storbinary('STOR ' + dest, f)
f.close() f.close()
ftp.close() ftp.close()
print "Done"
def changeDir(self, ftp, dir):
if dir not in ftp.nlst():
print "Creating dir '%s'" % dir
ftp.mkd(dir)
print "Changing to dir '%s'" % dir
ftp.cwd(dir)