Changes between Version 1 and Version 2 of Ticket #3567, comment 3


Ignore:
Timestamp:
11/14/2022 03:45:10 AM (13 months ago)
Author:
cesarmarcanove
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #3567, comment 3

    v1 v2  
    33https://stackoverflow.com/questions/66908593/oserror-winerror-87-the-parameter-is-incorrect 
    44 
     5 
    56{{{ 
     7Old Code (Causes OS Error 87) 
     8Example code: 
     9 
     10 
     11from fabric import task,SerialGroup,Connection 
     12import os 
     13 
     14USERNAME = os.getenv('USERNAME') 
     15my_hosts = ["hostname"] 
     16c = Connection(host="rg@host.com",connect_kwargs={"password":"abcd"}) 
     17@task 
     18def test(c): 
     19    print(USERNAME) 
     20    c.run("echo hello") 
     21 
     22}}} 
     23 
     24Then fixing: 
     25 
     26{{{ 
     27New code (no causes OS Error 87) 
     28Example Code 
     29Remplace to new code: 
     30 
     31from fabric import task,SerialGroup,Connection 
     32import os 
     33 
     34USERNAME = os.getenv('USERNAME') 
     35my_hosts = ["hostname"] 
     36c = Connection(host="rg@host.com",connect_kwargs={"password":"abcd"}) 
     37@task 
     38def test(c): 
     39    print(USERNAME) 
     40    c.run("echo hello", replace_env=False) 
     41 
     42}}} 
    643 
    744 
     
    1148Apparently, it shows up with Python 3.8 or 3.9, but not with 3.6 or 3.7. 
    1249 
    13 To get around it, you can use: c.run("echo hello", replace_env=False) 
     50To get around it, you can use: '''c.run("echo hello", replace_env=False)''' 
    1451 
    1552This is OK for local calls, but can be problematic for remote calls, because it means that the remote session will see all environment variable values (some of which may be sensitive) of your local session. 
    1653 
    1754 
    18 }}} 
    1955