How to get the files from a specified path in python? -


i copying set of zli files folder folder. need decompress each file in folder. running python using pycharm windows , folders in linux server. how can current folder , decompress each file?

from __future__ import with_statement fabric.api import * import configparser, paramiko, shutil, os, glob, zlib  def get_connection():     config = configparser.rawconfigparser()     config.read('config.cfg')     env.user = config.get('uk_cdn','db.user_name' )     env.password = config.get('uk_cdn','db.password' )     host = config.get('uk_cdn','db.ip' )      settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=true, host_string=host):     paramiko.util.log_to_file('enc_analysis.log')     files = run('ls -ltr /home/ndsuser/enc/data/dbschema_1/catalogue_24802')     run('rm -rf  /usr/rosh/enc_analysis/*')     run('cp /home/ndsuser/enc/data/dbschema_1/catalogue_24802/* /usr/rosh/enc_analysis/')     count = run('ls -l /usr/rosh/enc_analysis/ | wc -l')     os.chdir('/usr/rosh/enc_analysis/')     file in os.listdir('/usr/rosh/enc_analysis/'):         print file 

if run code, gets issue below.

  file "c:/work/scripts/vod/enc.py", line 20, in get_connection os.chdir('/usr/rosh/enc_analysis/') windowserror: [error 3] system cannot find path specified:  '/usr/rosh/enc_analysis/' 

i know issue due fact system not able find path in windows machine. how can path in linux server windows machine?

you can set pycharm automatically copy python script remote server , run there. pycharm documentation @ https://www.jetbrains.com/pycharm/help/configuring-remote-interpreters-via-ssh.html

since you've imported paramiko, send relevant commands on ssh session linux server, while running script locally. seems bit more awkward, still work.

sshconnection = paramiko.sshclient() sshconnection.connect(hostname, username=..., password=... ) stdin, stdout, stderr = sshconnection.exec_command('ls -ltr /home/...')  

and on.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -