subprocess.check_ouput is hanging up in eclipse and not taking backup for pg_dump in python langauage
Question: postgres dump is not working properly, i run the below python program through
eclipse with linux(ubuntu) background OS.

The problem is eclipse get hanged up and trace information as well as backup
file is empty.

    
    
    import os
    import subprocess
    
    if __name__ == '__main__':
        print "test hello"
    
        localhost = 'localhost'
        port = '5432'
        role = 'serverdb_user'
        dump_dir = '/home/backupfile/'
        db_username = 'empserverdb_user'
        db_names = 'emp1'
    
        try:
            bkp_file = 'backup1'
            file_path = os.path.join(dump_dir, bkp_file)
            print file_path
            dumper_cmd = ['pg_dump', '-h', localhost, '-p', port, '-U', db_username, '--role', role, '-W', '-Fc', '-v', '-f', file_path, db_names]
            print dumper_cmd
            subprocess.check_output(dumper_cmd)
        except subprocess.CalledProcessError, ex:
            print("Couldn't back up database {0}: pg_dump returned {1} with output {2}".format(db_names, ex.returncode, ex.output))
        except Exception, ex:
            print("Couldn't backup database {0}: unexpected error {1}".format(db_names, ex))
    

Please help where im doing wrong.


Answer: The problem get resolved by placing assigning password to env. As well as
people suggestion on post [Postgres Dump is strucked in eclipse, language used
is python](http://stackoverflow.com/questions/20882836/postgres-dump-is-
strucked-in-eclipse-language-used-is-python)

