Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session Persistence
#5
The traceback states "FileNotFoundError: [Errno 2] No such file or directory" and then lists a byte string that looks identical to a XML file:

Quote:b'\r\n\r\n<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\r\n<html>\r\n <head>\r\n\t<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r\n <title>THE Batch Server</title>\r\n <link rel="stylesheet" type="text/css" href="css/page.css"/>\r\n </head>\r\n <body>\r\n <h1>&nbsp;<img height="22" width="22" src="images/batchdefault.png"/>&nbsp;&nbsp;THE Batch Server Login</h1>\r\n \r\n \r\n Please log in to THE Batch Server with valid user which has access to use case \'Scheduled Jobs\'.\r\n \r\n <p/>\r\n <form method="post" action="login">\r\n <table border="0">\r\n <tbody>\r\n <tr>\r\n <td>User ID</td>\r\n <td>\r\n \r\n <input type="text" name="username">\r\n \r\n </td>\r\n </tr>\r\n <tr>\r\n <td>Password</td>\r\n <td><input type="password" name="password"></td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <input type="submit" value="Submit">\r\n </form>\r\n </body>\r\n</html>'

The core problem is that the expected filepath is a XML-formatted byte string.



Nevermind. I see what you're on about now. The documentation for requests.Session indicate that the username and password need to be set to the object, not just passed into the post() method:

s = requests.Session()
s.auth = ('user', 'pass')
s.headers.update({'x-test': 'true'})

# both 'x-test' and 'x-test2' are sent
s.get('https://httpbin.org/headers', headers={'x-test2': 'true'})
Try setting s.auth with the username and password.
Reply


Messages In This Thread
Session Persistence - by portuguesedanny - Jan-15-2019, 04:31 PM
RE: Session Persistence - by stullis - Jan-15-2019, 06:30 PM
RE: Session Persistence - by portuguesedanny - Jan-15-2019, 06:38 PM
RE: Session Persistence - by nilamo - Jan-15-2019, 06:47 PM
RE: Session Persistence - by stullis - Jan-15-2019, 10:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Powershell Session translation to Python; Session code seems to not work Maverick494 1 3,609 Jun-26-2018, 05:16 PM
Last Post: Maverick494

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020