def main(): if len(sys.argv) < 2: print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0] print 'Where [version] is the branch you want to checkout' print 'and username and password are for your eduforge account' print 'Eg. %s 0.7 --local' % sys.argv[0] else: version = sys.argv[1] branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version origDir = Path(sys.argv[0]).abspath().dirname() tmp = TempDirPath() os.chdir(tmp) os.system('svn export %s exe' % branch) (origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox') os.chdir(tmp/'exe') tarball = Path('../exe-%s-source.tgz' % version).abspath() os.system('tar czf %s *' % tarball) os.chdir(tmp) if '--local' not in sys.argv: try: from paramiko import Transport except ImportError: print 'To upload you need to install paramiko python library from:' print 'http://www.lag.net/paramiko' sys.exit(2) from socket import socket, gethostbyname s = socket() s.connect((gethostbyname('shell.eduforge.org'), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-2], sys.argv[-1]) f = t.open_sftp_client() f.chdir('/home/pub/exe') f.put(tarball.encode('utf8'), tarball.basename().encode('utf8')) if os.getuid() == 0: tarball.copyfile('/usr/portage/distfiles/' + tarball.basename()) os.chdir(tmp/'exe/installs/gentoo') newEbuildFilename = Path('exe-%s.ebuild' % version).abspath() if not newEbuildFilename.exists(): Path('exe-0.7.ebuild').copy(newEbuildFilename) if os.getuid() == 0: ebuildDir = Path('/usr/local/portage/dev-python/exe') if ebuildDir.exists(): ebuildDir.rmtree() ebuildDir.makedirs() os.chdir(ebuildDir) newEbuildFilename.copy(ebuildDir) filesDir = ebuildDir/'files' filesDir.makedirs() Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir) if '--local' not in sys.argv: oldTarball = Path('/usr/portage/distfiles/')/tarball.basename() if oldTarball.exists(): oldTarball.remove() os.environ['GENTOO_MIRRORS']='' os.system('ebuild %s fetch' % newEbuildFilename.basename()) os.system('ebuild %s manifest' % newEbuildFilename.basename()) os.system('ebuild %s digest' % newEbuildFilename.basename()) if '--install' in sys.argv: os.system('ebuild %s install' % newEbuildFilename.basename())
def main(): try: from paramiko import Transport except ImportError: print print 'To upload you need to install paramiko python library from:' print 'http://www.lag.net/paramiko', print 'or on ubuntu go: apt-get install python2.4-paramiko' print sys.exit(2) server = 'shell.eduforge.org' basedir = '/home/pub/exe/' print 'Please enter password for %s@%s:' % (sys.argv[-1], server) password = getpass() print 'Renaming files' install = Path('eXe_install_windows.exe') newName = Path('eXe-install-%s.exe' % release) install = renameFile(install, newName) ready2run = Path('exes.exe') newName = Path('eXe-ready2run-%s.exe' % release) ready2run = renameFile(ready2run, newName) print 'Uploading' print 'connecting to %s...' % server from socket import socket, gethostbyname s = socket() s.connect((gethostbyname(server), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-1], password) sftp = t.open_sftp_client() sftp.chdir(basedir) upFile(sftp, install) upFile(sftp, ready2run)
def _connect(self): host_id = self._host_cfg['host_id'] host, port = self._host_cfg[host_id, 'host'] user = self._host_cfg[host_id, 'user'] passwd = self._host_cfg[host_id, 'password'] timeout = self._host_cfg[host_id, 'timeout'] or None known_hosts = self._host_cfg[host_id, 'known_hosts'] key_type = self._host_cfg[host_id, 'key_type'] key_file = self._host_cfg[host_id, 'key_file'] key_pass = self._host_cfg[host_id, 'key_pass'] try: if key_type: key = _KEY_TYPES[key_type](filename=key_file, password=key_pass) _logger.debug('private key: %s', key.get_name()) else: key = None hostname = utils.format_knownhost(host, port) hostkeys = HostKeys(known_hosts) transport = Transport((host, port)) transport.start_client(timeout=timeout) hostkey = transport.get_remote_server_key() if not hostkeys.check(hostname, hostkey): raise SSHException('Incorrect hostkey') if key: transport.auth_publickey(user, key) else: transport.auth_password(user, passwd) client = transport.open_sftp_client() client.get_channel().settimeout(timeout) _logger.debug('client for %s created', hostname) return client except (OSError, SSHException) as ex: raise ConnectError(f'Connection to server "{host}:{port}"' f' failed: {ex.args!s}')
def _createConnection(self): """ @see: L{_createConnection<datafinder.persistence.common.connection.pool.ConnectionPool._createConnection>} """ try: connection = Transport((self._configuration.hostname, constants.DEFAULT_SSH_PORT)) connection.connect(username=self._configuration.username, password=self._configuration.password) return connection.open_sftp_client() except (SSHException, socket.error, socket.gaierror), error: errorMessage = u"Unable to establish SFTP connection to host '%s'! " \ % (self._configuration.hostname) + "\nReason: '%s'" % str(error) raise PersistenceError(errorMessage)
def main(): try: from paramiko import Transport except ImportError: print print "To upload you need to install paramiko python library from:" print "http://www.lag.net/paramiko", print "or on ubuntu go: apt-get install python2.4-paramiko" print sys.exit(2) # Setup for eduforge server = "shell.eduforge.org" basedir = "/home/pub/exe/" print "Please enter password for %s@%s:" % (sys.argv[-1], server) password = getpass() # Get the version # Rename the files print "Renaming files" install = Path("eXe_install_windows.exe") newName = Path("eXe-install-%s.exe" % release) install = renameFile(install, newName) ready2run = Path("exes.exe") newName = Path("eXe-ready2run-%s.exe" % release) ready2run = renameFile(ready2run, newName) # Upload print "Uploading" print "connecting to %s..." % server from socket import socket, gethostbyname s = socket() s.connect((gethostbyname(server), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-1], password) sftp = t.open_sftp_client() sftp.chdir(basedir) upFile(sftp, install) upFile(sftp, ready2run)
def main(): try: from paramiko import Transport except ImportError: print print 'To upload you need to install paramiko python library from:' print 'http://www.lag.net/paramiko', print 'or on ubuntu go: apt-get install python2.4-paramiko' print sys.exit(2) # Setup for eduforge server = 'shell.eduforge.org' basedir = '/home/pub/exe/' print 'Please enter password for %s@%s:' % (sys.argv[-1], server) password = getpass() # Get the version # Rename the files print 'Renaming files' install = Path('eXe_install_windows.exe') newName = Path('eXe-install-%s.exe' % release) install = renameFile(install, newName) ready2run = Path('exes.exe') newName = Path('eXe-ready2run-%s.exe' % release) ready2run = renameFile(ready2run, newName) # Upload print 'Uploading' print 'connecting to %s...' % server from socket import socket, gethostbyname s = socket() s.connect((gethostbyname(server), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-1], password) sftp = t.open_sftp_client() sftp.chdir(basedir) upFile(sftp, install) upFile(sftp, ready2run)
def sftp_client_from_transport(hostname, username, password): from paramiko import Transport tn = Transport((hostname, 22)) tn.connect(username=username, password=password) return tn.open_sftp_client()
os.system("dpkg-scanpackages pool /dev/null | gzip -9c > pool/Packages.gz") if "copy" in sys.argv: if "index" in sys.argv: print "copying index file to", exeDir (pool / "Packages.gz").copy(exeDir) pool = exeDir if server: print "connecting to %s..." % server from socket import socket, gethostbyname s = socket() s.connect((gethostbyname(server), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-1], password) f = t.open_sftp_client() f.chdir(basedir) poolDir = "ubuntu/pool" packageDirs = [ "ubuntu/dists/current/main/binary-i386", "ubuntu/dists/current/main/binary-arm", "ubuntu/dists/current/main/binary-alpha", ] if "checkDirs" in sys.argv: print "Checking directory structure..." for fn in packageDirs + [poolDir]: for part in fn.split("/"): files = f.listdir() if part not in files: print "Creating Dir on server:", fn, ":", part f.mkdir(part)
def main(): if len(sys.argv) < 2: print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0] print 'Where [version] is the branch you want to checkout' print 'and username and password are for your eduforge account' print 'Eg. %s 0.7 --local' % sys.argv[0] else: version = sys.argv[1] # Calc the svn branch name branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version # Get the original exe dir origDir = Path(sys.argv[0]).abspath().dirname() # Make the temp dir tmp = TempDirPath() os.chdir(tmp) # Do the export os.system('svn export %s exe' % branch) # Copy firefox accross (origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox') # Now make the tarball os.chdir(tmp/'exe') tarball = Path('../exe-%s-source.tgz' % version).abspath() os.system('tar czf %s *' % tarball) os.chdir(tmp) # Upload it if '--local' not in sys.argv: # Connect with sftp try: from paramiko import Transport except ImportError: print 'To upload you need to install paramiko python library from:' print 'http://www.lag.net/paramiko' sys.exit(2) from socket import socket, gethostbyname s = socket() s.connect((gethostbyname('shell.eduforge.org'), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-2], sys.argv[-1]) f = t.open_sftp_client() # See that the directory structure looks good f.chdir('/home/pub/exe') f.put(tarball.encode('utf8'), tarball.basename().encode('utf8')) # If we're root, copy the tarball to the portage cache dir to save # downloading it when emerging (for me anyway) if os.getuid() == 0: tarball.copyfile('/usr/portage/distfiles/' + tarball.basename()) # Copy the ebuild file os.chdir(tmp/'exe/installs/gentoo') newEbuildFilename = Path('exe-%s.ebuild' % version).abspath() if not newEbuildFilename.exists(): Path('exe-0.7.ebuild').copy(newEbuildFilename) # If we're root, rebuild the digests and remake the install if os.getuid() == 0: ebuildDir = Path('/usr/local/portage/dev-python/exe') if ebuildDir.exists(): ebuildDir.rmtree() ebuildDir.makedirs() os.chdir(ebuildDir) newEbuildFilename.copy(ebuildDir) # Copy the patch file filesDir = ebuildDir/'files' filesDir.makedirs() Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir) # Remove any old source if it exists and we're supposed to download # it if '--local' not in sys.argv: oldTarball = Path('/usr/portage/distfiles/')/tarball.basename() if oldTarball.exists(): oldTarball.remove() os.environ['GENTOO_MIRRORS']='' os.system('ebuild %s fetch' % newEbuildFilename.basename()) os.system('ebuild %s manifest' % newEbuildFilename.basename()) os.system('ebuild %s digest' % newEbuildFilename.basename()) if '--install' in sys.argv: os.system('ebuild %s install' % newEbuildFilename.basename())
def main(): if len(sys.argv) < 2: print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0] print 'Where [version] is the branch you want to checkout' print 'and username and password are for your eduforge account' print 'Eg. %s 0.7 --local' % sys.argv[0] else: version = sys.argv[1] # Calc the svn branch name branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version # Get the original exe dir origDir = Path(sys.argv[0]).abspath().dirname() # Make the temp dir tmp = TempDirPath() os.chdir(tmp) # Do the export os.system('svn export %s exe' % branch) # Copy firefox accross (origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox') # Now make the tarball os.chdir(tmp/'exe') tarball = Path('../exe-%s-source.tgz' % version).abspath() os.system('tar czf %s *' % tarball) os.chdir(tmp) # Upload it if '--local' not in sys.argv: # Connect with sftp try: from paramiko import Transport except ImportError: print 'To upload you need to install paramiko python library from:' print 'http://www.lag.net/paramiko' sys.exit(2) from socket import socket, gethostbyname s = socket() s.connect((gethostbyname('shell.eduforge.org'), 22)) t = Transport(s) t.connect() t.auth_password(sys.argv[-2], sys.argv[-1]) f = t.open_sftp_client() # See that the directory structure looks good f.chdir('/home/pub/exe') f.put(tarball.encode('utf8'), tarball.basename().encode('utf8')) # If we're root, copy the tarball to the portage cache dir to save # downloading it when emerging (for me anyway) if os.getuid() == 0: tarball.copyfile('/usr/portage/distfiles/' + tarball.basename()) # Copy the ebuild file os.chdir(tmp/'exe/installs/gentoo') newEbuildFilename = Path('exe-%s.ebuild' % version).abspath() if not newEbuildFilename.exists(): Path('exe-0.7.ebuild').copy(newEbuildFilename) # If we're root, rebuild the digests and remake the install if os.getuid() == 0: ebuildDir = Path('/usr/local/portage/dev-python/exe') if ebuildDir.exists(): ebuildDir.rmtree() ebuildDir.makedirs() os.chdir(ebuildDir) newEbuildFilename.copy(ebuildDir) # Copy the patch file filesDir = ebuildDir/'files' filesDir.makedirs() Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir) # Remove any old source if it exists and we're supposed to download # it if '--local' not in sys.argv: oldTarball = Path('/usr/portage/distfiles/')/tarball.basename() if oldTarball.exists(): oldTarball.remove() os.environ['GENTOO_MIRRORS']='' os.system('ebuild %s fetch' % newEbuildFilename.basename()) os.system('ebuild %s manifest' % newEbuildFilename.basename()) os.system('ebuild %s digest' % newEbuildFilename.basename()) if '--install' in sys.argv: os.system('ebuild %s install' % newEbuildFilename.basename())