Re: Question regarding the local function object
Terry Reedy wrote: I believe that CPython function objects must currently all have the same size or at least the same max size and conclude that CPython currently allocates them from a block of memory that is some multiple of that size. I wouldn't be surprised if there is a free list for function objects, which would make it even more likely that you would observe this kind of re-use. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: how to embed non-tkinter VLC player into grid of tkinter with python?
how to add video within tkinter frame.I am trying to add multiple videos inside the frame. -- https://mail.python.org/mailman/listinfo/python-list
Re: subprocess svn checkout password issue
On 3/16/19 1:50 AM, Martin De Kauwe wrote:
On Saturday, 16 March 2019 16:50:23 UTC+11, dieter wrote:
Martin De Kauwe writes:
> I'm trying to write a script that will make a checkout from a svn repo and build the result for the user. However, when I attempt to interface with the shell it asks the user for their filename and I don't know how to capture this with my implementation.
[...]
That is non-trivial.
Read the "svn" documentation. You might be able to pass in the
required information by other means, maybe an option, maybe
an envvar, maybe via a configuration file.
Otherwise, you must monitor what it written to the subprocess'
"stdout" and "stderr", recognized the interaction request
perform the interaction with the user and send the result
to the subprocess' stdin.
Thanks, I think this solution will work.
import subprocess
import getpass
user = "XXX578"
root="https://trac.nci.org.au/svn/cable";
repo_name = "CMIP6-MOSRS"
pswd = "'" + getpass.getpass('Password:') + "'"
cmd = "svn checkout %s/branches/Users/%s/%s --password %s" %\
(root, user, repo_name, pswd)
I'm not questioning whether or not that will work, but I will
point out that the password will be exposed to anyone doing a
process listing when that process is running (e.g., "ps -ef"
on a posix-like system). This may or may not be an issue for
your use case.
error = subprocess.call(cmd, shell=True)
if error is 1:
raise("Error checking out repo")
--
https://mail.python.org/mailman/listinfo/python-list
Re: subprocess svn checkout password issue
On 2019-03-16, dieter wrote: > Otherwise, you must monitor what it written to the subprocess' > "stdout" and "stderr", recognized the interaction request > perform the interaction with the user and send the result > to the subprocess' stdin. I don't know about svn specifically, but in the past it was typical for programs requiring passwords and assuming interactive usage to issue the password prompt to and read the password from /dev/tty, rather than stdin/stdout. That allowed their use in a pipeline without contaminating the pipe's data with the password prompt and password. In "normal" usage /dev/tty and stdin/stdout/stderr are all the same device, but when used via a library like subprocess, you couldn't provide the password via stdin. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: mocking for get method in requests
Shakti Kumar ezt írta (időpont: 2019. jan.
18., P, 18:18):
> Hello people,
> I noticed something weird (weird as per my current knowledge, though I know
> its subjective) today.
>
> sample.py file
>
> --
>
> import requests
> def random_testing():
> out = requests.get('www.cisco.com')
> a = out.json()
> return a
>
>
> testing.py file
>
> --
>
> @patch(*’*sample.requests')
> def test_random_testing(self, mock_req):
> mock_req.get('').return_value = 'Hello'
> out = api.random_testing()
>
>
> Patching the sample.requests in this way does not lead the output of
> requests.get() function in sample.py file to be ‘Hello’ as indicated
> in
> mock_req.get('').return_value = 'Hello'
> Instead, it creates a new field called return_value in ‘out', and
> hence out.return_value is ‘Hello’ instead of just ‘out’.
>
> But if I patch it as,
>
> @patch(*’*sample.requests')
> def test_random_testing(self, mock_req):
> mock_req.get.return_value = 'Hello'
> out = api.random_testing()
>
> It does give the value of ‘out’ as ‘Hello’ in sample.py file.
> I know I am missing something, which is where I need some help :)
>
> Thanks.
>
> --
>
>
>
> UG, CSE,
> RVCE, Bengaluru.
> --
> https://mail.python.org/mailman/listinfo/python-list
Hi Kumar,
I saw that there was no answer.
Perhaps you should check PyTest
https://docs.pytest.org/en/latest/contents.html
it has several plugins, it can mock, and can do much things.
BR,
George
--
https://mail.python.org/mailman/listinfo/python-list
Re: subprocess svn checkout password issue
On 03/16/2019 10:08 AM, Grant Edwards wrote: > I don't know about svn specifically, but in the past it was typical > for programs requiring passwords and assuming interactive usage to > issue the password prompt to and read the password from /dev/tty, > rather than stdin/stdout. That allowed their use in a pipeline > without contaminating the pipe's data with the password prompt and > password. In "normal" usage /dev/tty and stdin/stdout/stderr are all > the same device, but when used via a library like subprocess, you > couldn't provide the password via stdin. There's a python library (Linux and Unix only I think) called pexpect[1] that can drive programs that expect a pty for taking password input. [1] https://pypi.org/project/pexpect/ -- https://mail.python.org/mailman/listinfo/python-list
