Exemplo n.º 1
0
 def onUpload(self):
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     ssh = sshsftp.ssh_connect(host, user, passwd)
     calcid = self.newcalcid_tc.GetValue()
     calcdir = path+calcid
     gbw_count = 0
     localdir = '\\'.join(self.oldpath_tc.GetValue().split('\\')[:-1])+ '\\'
     sftp.chdir(path)
     if calcdir not in sftp.listdir():
         try:
             sftp.mkdir(calcid)
         except IOError:
             print 'Error'
     else:
         sftp.chdir(calcdir)
     sftp.chdir(path + calcid)
     for name in os.listdir(localdir):
         localfile = localdir+name
         remotefile = path+calcid+'/'+name
         if name.endswith(".in"):
             sftp.put(localdir+name,path+'/'+calcid+'/'+name)
         elif name.endswith(".gbw"):
             gbw_count += 1
             with open('transfer.txt','a') as f:
                 if gbw_count == 1:
                     f.write('option batch on\noption confirm off\n')
                     connect_string = 'open sftp://%s:%s@%s\n' %(user,passwd,host)
                     f.write(connect_string)
                 upld_string = 'put -transfer=ascii %s %s\n' %(localfile, remotefile)
                 f.write(upld_string)
     if os.path.isfile('transfer.txt'):
         os.system('winscp.exe /script=transfer.txt')
         os.remove('transfer.txt')
Exemplo n.º 2
0
 def onDownload(self,event):
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     ssh = sshsftp.ssh_connect(host, user, passwd)
     calcid = self.getCalcID()
     calcdir = path+calcid
     gbw_count = 0
     localdir = '\\'.join(self.tc0.GetValue().split('\\')[:-1])+ '\\'
     sftp.chdir(path)
     if calcdir not in sftp.listdir():
         sftp.chdir(calcdir)
     for name in sftp.listdir():
         remotefile = path + calcid + '/'+ name
         localpath = '\\'.join(self.tc0.GetValue().split('\\')[:-1])+ '\\'
         localfile = localpath + name
         if not name.endswith('.gbw'):
             sftp.get(remotefile,localfile)
         else:
             gbw_count += 1
             with open('transfer.txt','a') as f:
                 if gbw_count == 1:
                     cmd = 'cd %s' %calcdir
                     cmd2 = '~/bin/unix2dos.sh'
                     stdin, stdout, stderr = ssh.exec_command(cmd+';'+cmd2)
                     f.write('option batch on\noption confirm off\n')
                     connect_string = 'open sftp://%s:%s@%s\n' %(user,passwd,host)
                     f.write(connect_string)
                 upld_string = 'get -transfer=ascii %s %s\n' %(remotefile, localfile)
                 f.write(upld_string)
     if os.path.isfile('transfer.txt'):
         os.system('winscp.exe /script=transfer.txt')
         os.remove('transfer.txt')
     wx.MessageBox('Download Complete', 'Info', wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 3
0
 def onPlotOrb(self, event):
     orbs = ''
     orb_list = gen.getColumn(self.lc)
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     ssh = sshsftp.ssh_connect(host, user, passwd)
     calcid = self.getCalcID()
     calcdir = path + calcid
     gbw_count = 0
     localdir = '\\'.join(self.tc0.GetValue().split('\\')[:-1]) + '\\'
     cmd1 = 'cd %s' % path + calcid
     sftp.chdir(path)
     if calcdir not in sftp.listdir():
         try:
             sftp.mkdir(calcid)
         except IOError:
             pass
     else:
         sftp.chdir(calcdir)
     sftp.chdir(path + calcid)
     for name in os.listdir(localdir):
         localfile = localdir + name
         remotefile = path + calcid + '/' + name
         if name.endswith(".out") or name.endswith(".in"):
             sftp.put(localdir + name, path + '/' + calcid + '/' + name)
         elif name.endswith(".gbw"):
             gbw_count += 1
             with open('transfer.txt', 'a') as f:
                 if gbw_count == 1:
                     f.write('option batch on\noption confirm off\n')
                     connect_string = 'open sftp://%s:%s@%s\n' % (
                         user, passwd, host)
                     f.write(connect_string)
                 upld_string = 'put -transfer=ascii %s %s\n' % (localfile,
                                                                remotefile)
                 f.write(upld_string)
     if os.path.isfile('transfer.txt'):
         os.system('winscp.exe /script=transfer.txt')
         os.remove('transfer.txt')
     for orbital in orb_list:
         orbs += str(orbital) + ' '
     cmd2 = 'cask %s -plot ' % calcid + orbs
     stdin, stdout, stderr = ssh.exec_command(cmd1 + ';' + cmd2)
     print stdout.readlines()
     for file_name in sftp.listdir():
         if not file_name.endswith(".gbw"):
             f = path + calcid + '/' + file_name
             local = '\\'.join(
                 self.tc0.GetValue().split('\\')[:-1]) + '\\' + file_name
             sftp.get(f, local)
     ssh.close()
     wx.MessageBox('Orbital Plotting Finished', 'Info',
                   wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 4
0
 def onDelete(self, event):
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     calcid = self.getCalcID()
     calcdir = path + calcid
     files = sftp.listdir(calcdir)
     for name in files:
         filepath = calcdir + '/' + name
         try:
             sftp.remove(filepath)
         except IOError:
             self.onDelete(filepath)
     sftp.rmdir(calcdir)
     wx.MessageBox('Folder Deleted', 'Info', wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 5
0
 def onDelete(self,event):
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     calcid = self.getCalcID()
     calcdir = path+calcid
     files = sftp.listdir(calcdir)
     for name in files:
         filepath = calcdir + '/' + name
         try:
             sftp.remove(filepath)
         except IOError:
             self.onDelete(filepath)
     sftp.rmdir(calcdir)
     wx.MessageBox('Folder Deleted', 'Info', wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 6
0
 def onPlotOrb(self, event):
     orbs = ''
     orb_list = gen.getColumn(self.lc)
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     ssh = sshsftp.ssh_connect(host, user, passwd)
     calcid = self.getCalcID()
     calcdir = path+calcid
     gbw_count = 0
     localdir = '\\'.join(self.tc0.GetValue().split('\\')[:-1])+ '\\'
     cmd1 = 'cd %s' %path + calcid
     sftp.chdir(path)
     if calcdir not in sftp.listdir():
         try:
             sftp.mkdir(calcid)
         except IOError:
             pass
     else:
         sftp.chdir(calcdir)
     sftp.chdir(path + calcid)
     for name in os.listdir(localdir):
         localfile = localdir+name
         remotefile = path+calcid+'/'+name
         if name.endswith(".out") or name.endswith(".in"):
             sftp.put(localdir+name,path+'/'+calcid+'/'+name)
         elif name.endswith(".gbw"):
             gbw_count += 1
             with open('transfer.txt','a') as f:
                 if gbw_count == 1:
                     f.write('option batch on\noption confirm off\n')
                     connect_string = 'open sftp://%s:%s@%s\n' %(user,passwd,host)
                     f.write(connect_string)
                 upld_string = 'put -transfer=ascii %s %s\n' %(localfile, remotefile)
                 f.write(upld_string)
     if os.path.isfile('transfer.txt'):
         os.system('winscp.exe /script=transfer.txt')
         os.remove('transfer.txt')
     for orbital in orb_list:
         orbs += str(orbital) +' '
     cmd2 = 'cask %s -plot ' %calcid + orbs
     stdin, stdout, stderr = ssh.exec_command(cmd1 + ';' + cmd2)
     print stdout.readlines()
     for file_name in sftp.listdir():
         if not file_name.endswith(".gbw"):
             f = path + calcid + '/'+ file_name
             local = '\\'.join(self.tc0.GetValue().split('\\')[:-1])+ '\\' + file_name
             sftp.get(f,local)
     ssh.close()
     wx.MessageBox('Orbital Plotting Finished', 'Info', wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 7
0
 def onUpload(self):
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     ssh = sshsftp.ssh_connect(host, user, passwd)
     calcid = self.newcalcid_tc.GetValue()
     calcdir = path + calcid
     gbw_count = 0
     localdir = '\\'.join(
         self.oldpath_tc.GetValue().split('\\')[:-1]) + '\\'
     sftp.chdir(path)
     if calcdir not in sftp.listdir():
         try:
             sftp.mkdir(calcid)
         except IOError:
             print 'Error'
     else:
         sftp.chdir(calcdir)
     sftp.chdir(path + calcid)
     for name in os.listdir(localdir):
         localfile = localdir + name
         remotefile = path + calcid + '/' + name
         if name.endswith(".in"):
             sftp.put(localdir + name, path + '/' + calcid + '/' + name)
         elif name.endswith(".gbw"):
             gbw_count += 1
             with open('transfer.txt', 'a') as f:
                 if gbw_count == 1:
                     f.write('option batch on\noption confirm off\n')
                     connect_string = 'open sftp://%s:%s@%s\n' % (
                         user, passwd, host)
                     f.write(connect_string)
                 upld_string = 'put -transfer=ascii %s %s\n' % (localfile,
                                                                remotefile)
                 f.write(upld_string)
     if os.path.isfile('transfer.txt'):
         os.system('winscp.exe /script=transfer.txt')
         os.remove('transfer.txt')
Exemplo n.º 8
0
 def onDownload(self, event):
     host, path, user, passwd = sshsftp.getLogin(self.computers.GetValue())
     sftp = sshsftp.sftp_connect(host, path, user, passwd)
     ssh = sshsftp.ssh_connect(host, user, passwd)
     calcid = self.getCalcID()
     calcdir = path + calcid
     gbw_count = 0
     localdir = '\\'.join(self.tc0.GetValue().split('\\')[:-1]) + '\\'
     sftp.chdir(path)
     if calcdir not in sftp.listdir():
         sftp.chdir(calcdir)
     for name in sftp.listdir():
         remotefile = path + calcid + '/' + name
         localpath = '\\'.join(self.tc0.GetValue().split('\\')[:-1]) + '\\'
         localfile = localpath + name
         if not name.endswith('.gbw'):
             sftp.get(remotefile, localfile)
         else:
             gbw_count += 1
             with open('transfer.txt', 'a') as f:
                 if gbw_count == 1:
                     cmd = 'cd %s' % calcdir
                     cmd2 = '~/bin/unix2dos.sh'
                     stdin, stdout, stderr = ssh.exec_command(cmd + ';' +
                                                              cmd2)
                     f.write('option batch on\noption confirm off\n')
                     connect_string = 'open sftp://%s:%s@%s\n' % (
                         user, passwd, host)
                     f.write(connect_string)
                 upld_string = 'get -transfer=ascii %s %s\n' % (remotefile,
                                                                localfile)
                 f.write(upld_string)
     if os.path.isfile('transfer.txt'):
         os.system('winscp.exe /script=transfer.txt')
         os.remove('transfer.txt')
     wx.MessageBox('Download Complete', 'Info', wx.OK | wx.ICON_INFORMATION)