Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Are we running light with overbyte?


devel / comp.lang.python / How to test input via subprocess.Popen with data from file

SubjectAuthor
* How to test input via subprocess.Popen with data from fileLoris Bennett
+- Re: How to test input via subprocess.Popen with data from fileDieter Maurer
+- Re: How to test input via subprocess.Popen with data from fileLoris Bennett
+- Re: How to test input via subprocess.Popen with data from fileDieter Maurer
+- Re: How to test input via subprocess.Popen with data from fileRoel Schroeven
+* Re: How to test input via subprocess.Popen with data from fileRoel Schroeven
|`- Re: How to test input via subprocess.Popen with data from fileBhavesh Kunar
`- Re: How to test input via subprocess.Popen with data from fileTobiah

1
How to test input via subprocess.Popen with data from file

<878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17449&group=comp.lang.python#17449

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.be...@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: How to test input via subprocess.Popen with data from file
Date: Thu, 10 Mar 2022 13:16:11 +0100
Organization: Freie Universitaet Berlin
Lines: 45
Message-ID: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de QnSCqdQj19syhq6HPM04cwwhJcoDyl9Ejha7v/UIYCB+M4
Cancel-Lock: sha1:TjbTNwJfu1GkU+N60S+MPAtqFm0=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Loris Bennett - Thu, 10 Mar 2022 12:16 UTC

Hi,

I have a command which produces output like the
following:

Job ID: 9431211
Cluster: curta
User/Group: build/staff
State: COMPLETED (exit code 0)
Nodes: 1
Cores per node: 8
CPU Utilized: 01:30:53
CPU Efficiency: 83.63% of 01:48:40 core-walltime
Job Wall-clock time: 00:13:35
Memory Utilized: 6.45 GB
Memory Efficiency: 80.68% of 8.00 GB

I want to parse this and am using subprocess.Popen and accessing the
contents via Popen.stdout. However, for testing purposes I want to save
various possible outputs of the command as text files and use those as
inputs.

What format should I use to pass data to the actual parsing function?

I could in both production and test convert the entire input to a string
and pass the string to the parsing method.

However, I could use something like

test_input_01 = subprocess.Popen(
["cat test_input_01.txt"],
stdout=subprocess.PIPE,
)

for the test input and then pass a Popen object to the parsing function.

Any comments on these alternative or suggestions for doing something
completely different?

Cheers,

Loris
--
This signature is currently under construction.

Re: How to test input via subprocess.Popen with data from file

<mailman.261.1646933108.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17456&group=comp.lang.python#17456

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: die...@handshake.de (Dieter Maurer)
Newsgroups: comp.lang.python
Subject: Re: How to test input via subprocess.Popen with data from file
Date: Thu, 10 Mar 2022 18:24:59 +0100
Lines: 30
Message-ID: <mailman.261.1646933108.2329.python-list@python.org>
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<25130.13419.321314.959918@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de ZETpbdsOfC31KU3caqbIogbLhx4m16KCbtJ2lGSYZxUg==
Return-Path: <dieter@handshake.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'cpu': 0.07; 'view,': 0.07;
'cc:addr:python-list': 0.09; 'parse': 0.09; 'subject:test': 0.09;
'test,': 0.09; 'text.': 0.09; 'cc:no real name:2**0': 0.14;
'memory': 0.15; 'bennett': 0.16; 'outputs': 0.16; 'parsing': 0.16;
'separately': 0.16; 'cc:addr:python.org': 0.20; 'purposes': 0.22;
'subject:file': 0.22; 'code': 0.23; 'command': 0.23;
'subject:How': 0.23; 'received:de': 0.23; 'actual': 0.25;
'cc:2**0': 0.25; 'output': 0.28; 'header:In-Reply-To:1': 0.34;
'files': 0.36; 'those': 0.36; 'subject:from': 0.37; 'using': 0.37;
'file': 0.38; 'read': 0.38; 'text': 0.39; 'use': 0.39; 'wrote':
0.39; 'both': 0.40; 'want': 0.40; 'accessing': 0.64; 'your': 0.64;
'process.': 0.65; 'header:Received:6': 0.67; 'per': 0.68;
'subject:skip:s 10': 0.69; 'relevant': 0.73; 'produces': 0.76;
'time:': 0.81; 'received:88': 0.84
In-Reply-To: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <25130.13419.321314.959918@ixdm.fritz.box>
X-Mailman-Original-References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
 by: Dieter Maurer - Thu, 10 Mar 2022 17:24 UTC

Loris Bennett wrote at 2022-3-10 13:16 +0100:
>I have a command which produces output like the
>following:
>
> Job ID: 9431211
> Cluster: curta
> User/Group: build/staff
> State: COMPLETED (exit code 0)
> Nodes: 1
> Cores per node: 8
> CPU Utilized: 01:30:53
> CPU Efficiency: 83.63% of 01:48:40 core-walltime
> Job Wall-clock time: 00:13:35
> Memory Utilized: 6.45 GB
> Memory Efficiency: 80.68% of 8.00 GB
>
>I want to parse this and am using subprocess.Popen and accessing the
>contents via Popen.stdout. However, for testing purposes I want to save
>various possible outputs of the command as text files and use those as
>inputs.

What do you want to test? the parsing? the "popen" interaction?
You can separately test both tasks (I, at your place, would do this).

For the parsing test, it is not relevant that the actual text
comes from an external process. You can directly read it from a file
or have it in your text.

In my view, you do not need a test for the `Popen` interaction:
if it works once, it will work always.

Re: How to test input via subprocess.Popen with data from file

<mailman.268.1646981059.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17465&group=comp.lang.python#17465

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.be...@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: How to test input via subprocess.Popen with data from file
Date: Fri, 11 Mar 2022 07:40:52 +0100
Lines: 50
Message-ID: <mailman.268.1646981059.2329.python-list@python.org>
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<25130.13419.321314.959918@ixdm.fritz.box>
<8735jpf0uj.fsf@hornfels.zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de CDEJZtwt4Rp8yd00KgBFqQb9tx6IlthgFNq0ZeiH4bxg==
Return-Path: <loris@zedat.fu-berlin.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'cpu':
0.07; 'string': 0.07; 'tests': 0.07; 'view,': 0.07; 'be?': 0.09;
'cc:addr:python-list': 0.09; 'parse': 0.09; 'subject:test': 0.09;
'test,': 0.09; 'text.': 0.09; 'writes:': 0.09; 'cheers,': 0.11;
'cc:no real name:2**0': 0.14; 'memory': 0.15; 'bennett': 0.16;
'dieter': 0.16; 'indeed': 0.16; 'outputs': 0.16; 'parsing': 0.16;
'separately': 0.16; 'strings,': 0.16; 'cc:addr:python.org': 0.20;
'input': 0.21; 'maybe': 0.22; 'purposes': 0.22; 'subject:file':
0.22; 'code': 0.23; 'command': 0.23; 'subject:How': 0.23;
'received:de': 0.23; 'actual': 0.25; 'cc:2**0': 0.25; 'object':
0.26; 'function': 0.27; 'output': 0.28; 'header:User-Agent:1':
0.30; 'question': 0.32; 'but': 0.32; 'header:In-Reply-To:1': 0.34;
'files': 0.36; 'those': 0.36; 'currently': 0.37; 'subject:from':
0.37; 'using': 0.37; 'file': 0.38; 'read': 0.38; 'single': 0.39;
'text': 0.39; 'mentioned': 0.39; 'list': 0.39; 'use': 0.39;
'wrote': 0.39; 'files.': 0.40; 'both': 0.40; 'want': 0.40;
'should': 0.40; 'sorry': 0.60; 'format': 0.62; 'accessing': 0.64;
'your': 0.64; 'process.': 0.65; 'per': 0.68; 'subject:skip:s 10':
0.69; 'relevant': 0.73; 'produces': 0.76; 'signature': 0.76;
'time:': 0.81
In-Reply-To: <25130.13419.321314.959918@ixdm.fritz.box> (Dieter Maurer's
message of "Thu, 10 Mar 2022 18:24:59 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
X-Original-Sender: loris.bennett@fu-berlin.de
X-Originating-IP: 130.133.144.203
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <8735jpf0uj.fsf@hornfels.zedat.fu-berlin.de>
X-Mailman-Original-References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<25130.13419.321314.959918@ixdm.fritz.box>
 by: Loris Bennett - Fri, 11 Mar 2022 06:40 UTC

Dieter Maurer <dieter@handshake.de> writes:

> Loris Bennett wrote at 2022-3-10 13:16 +0100:
>>I have a command which produces output like the
>>following:
>>
>> Job ID: 9431211
>> Cluster: curta
>> User/Group: build/staff
>> State: COMPLETED (exit code 0)
>> Nodes: 1
>> Cores per node: 8
>> CPU Utilized: 01:30:53
>> CPU Efficiency: 83.63% of 01:48:40 core-walltime
>> Job Wall-clock time: 00:13:35
>> Memory Utilized: 6.45 GB
>> Memory Efficiency: 80.68% of 8.00 GB
>>
>>I want to parse this and am using subprocess.Popen and accessing the
>>contents via Popen.stdout. However, for testing purposes I want to save
>>various possible outputs of the command as text files and use those as
>>inputs.
>
> What do you want to test? the parsing? the "popen" interaction?
> You can separately test both tasks (I, at your place, would do this).

I just want to test the parsing.

> For the parsing test, it is not relevant that the actual text
> comes from an external process. You can directly read it from a file
> or have it in your text.

As mentioned in the original post, for the tests I indeed want to read
the input from files.

> In my view, you do not need a test for the `Popen` interaction:
> if it works once, it will work always.

Sorry if I was unclear but my question is:

Given that the return value from Popen is a Popen object and given that
the return value from reading a file is a single string or maybe a list
of strings, what should the common format for the argument which is
passed to the actual parsing function be?

Cheers,

Loris
--
This signature is currently under construction.

Re: How to test input via subprocess.Popen with data from file

<mailman.269.1646981802.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17466&group=comp.lang.python#17466

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: die...@handshake.de (Dieter Maurer)
Newsgroups: comp.lang.python
Subject: Re: How to test input via subprocess.Popen with data from file
Date: Fri, 11 Mar 2022 07:56:39 +0100
Lines: 21
Message-ID: <mailman.269.1646981802.2329.python-list@python.org>
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<25130.13419.321314.959918@ixdm.fritz.box>
<8735jpf0uj.fsf@hornfels.zedat.fu-berlin.de>
<25130.62119.387483.126247@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de K2tcIPMxXtO4z2HNBx018AFKflV6bGnQWkEOFkv2K81Q==
Return-Path: <dieter@handshake.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.04;
'assumes': 0.07; 'string': 0.07; 'be?': 0.09; 'cc:addr:python-
list': 0.09; 'methods,': 0.09; 'subject:test': 0.09; 'cc:no real
name:2**0': 0.14; 'assumptions': 0.16; 'bennett': 0.16; 'input.':
0.16; 'parsing': 0.16; 'strings,': 0.16; 'use?': 0.16; 'uses':
0.19; 'cc:addr:python.org': 0.20; 'input': 0.21; 'maybe': 0.22;
'subject:file': 0.22; 'subject:How': 0.23; 'received:de': 0.23;
'actual': 0.25; 'cc:2**0': 0.25; 'object': 0.26; 'function': 0.27;
'question': 0.32; 'ease': 0.32; 'objects': 0.32; 'said,': 0.32;
'but': 0.32; 'header:In-Reply-To:1': 0.34; 'subject:from': 0.37;
'file': 0.38; 'single': 0.39; 'list': 0.39; 'methods': 0.39;
'wrote': 0.39; 'want': 0.40; 'should': 0.40; 'likely': 0.61;
'format': 0.62; 'pass': 0.64; 'header:Received:6': 0.67;
'subject:skip:s 10': 0.69; 'chance': 0.71; '(such': 0.84;
'received:88': 0.84
In-Reply-To: <8735jpf0uj.fsf@hornfels.zedat.fu-berlin.de>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <25130.62119.387483.126247@ixdm.fritz.box>
X-Mailman-Original-References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<25130.13419.321314.959918@ixdm.fritz.box>
<8735jpf0uj.fsf@hornfels.zedat.fu-berlin.de>
 by: Dieter Maurer - Fri, 11 Mar 2022 06:56 UTC

Loris Bennett wrote at 2022-3-11 07:40 +0100:
> ... I want to test the parsing ...
>Sorry if I was unclear but my question is:
>
>Given that the return value from Popen is a Popen object and given that
>the return value from reading a file is a single string or maybe a list
>of strings, what should the common format for the argument which is
>passed to the actual parsing function be?

What methods (of its input argument) does the parsing use?
If it uses `Popen` methods, then you pass a `POpen` object;
if it uses only (typical) file methods, then you pass a file object;
if it assumes its input to be a (line) interator, you pass
a (line) iterator (such as a "file" object).

I would design the parsing that it makes as few assumptions
about its input as possible -- to ease testing
and increase the chance for reuse.

That said, I would not design it to work with `Popen` objects
but likely to have a line iterator as input.

Re: How to test input via subprocess.Popen with data from file

<mailman.272.1646989890.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17469&group=comp.lang.python#17469

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: roe...@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: How to test input via subprocess.Popen with data from file
Date: Fri, 11 Mar 2022 10:11:26 +0100
Lines: 47
Message-ID: <mailman.272.1646989890.2329.python-list@python.org>
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<33e51b22-3d1e-7c17-7aac-385294712120@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de AT39pUDiVLkvjDBstgc6aQgAlSffcq6uG30NvAqpzLBQ==
Return-Path: <roel@roelschroeven.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=roelschroeven.net header.i=@roelschroeven.net
header.b=jib6l730; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'stream': 0.04; 'bunch':
0.05; 'cpu': 0.07; 'byte': 0.09; 'parse': 0.09; 'string,': 0.09;
'subject:test': 0.09; 'memory': 0.15; '"don\'t': 0.16; 'captured':
0.16; 'generates': 0.16; 'instance': 0.16; 'long-running': 0.16;
'outputs': 0.16; 'parsing': 0.16; 'passed.': 0.16;
'received:10.202': 0.16; 'received:10.202.2': 0.16;
'received:10.202.2.163': 0.16; 'received:64.147': 0.16;
'received:64.147.123': 0.16; 'received:64.147.123.24': 0.16;
'received:internal': 0.16; 'received:messagingengine.com': 0.16;
'received:wout1-smtp.messagingengine.com': 0.16; 'run,': 0.16;
'schreef': 0.16; 'stdout': 0.16; 'strings,': 0.16; 'problem':
0.16; 'instead': 0.17; 'to:addr:python-list': 0.20; 'purposes':
0.22; 'returns': 0.22; 'subject:file': 0.22; 'code': 0.23;
'command': 0.23; 'lines': 0.23; 'subject:How': 0.23; 'actual':
0.25; 'function': 0.27; 'output': 0.28; 'header:User-Agent:1':
0.30; 'whole': 0.30; 'program': 0.31; '(as': 0.32; 'same': 0.34;
'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'files': 0.36;
'those': 0.36; 'guide': 0.37; 'subject:from': 0.37; 'using': 0.37;
"it's": 0.37; 'file': 0.38; 'read': 0.38; 'text': 0.39; 'use':
0.39; 'want': 0.40; 'should': 0.40; 'format': 0.62; 'simply':
0.63; 'pass': 0.64; 'accessing': 0.64; 'your': 0.64;
'received:64': 0.67; 'per': 0.68; 'exactly': 0.68; 'following:':
0.69; 'subject:skip:s 10': 0.69; 'depending': 0.70; 'content':
0.72; 'produces': 0.76; 'time:': 0.81; 'worry': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:date:date:from:from:in-reply-to:in-reply-to:message-id
:mime-version:references:reply-to:sender:subject:subject:to:to;
s=fm3; bh=9gWxVYACePXzYEJdnm2Ym+uO1EgOeoB+EN0baY22r+c=; b=jib6l
730jvGpDgSwdg2ddtZgTJl+Zd5B+l3M2BkAFTnBB8eJda5n1FbMVGFSpJmhwWSuk
2KZHjrIqD1h4Sxcq3biBn3aP38Ajwl5is+7Kx9sN0QsOq/V0H6oYAsTYbnIAyBN/
yh/JsUKfsoRB6GsXMY943hgpmxtQexnDHuMFuBBPdNk+I4N1IfkeTmy+Apzt/FSK
MqJI7k6hFoKU44RVVqlXICNbqat5M7gYXOTALPTDsKnkgDJeN/7cIM/SJoFEzSGs
+JoH9NsMe2Y8iU2DmLn3FE1k6r7Y6eKytktDkq/30rkqiVqoFE+qFgfbNcsawYeo
OP+s5odQTQomIhR0A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:date:date:from:from:in-reply-to:in-reply-to:message-id
:mime-version:references:reply-to:sender:subject:subject:to:to
:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
fm2; bh=9gWxVYACePXzYEJdnm2Ym+uO1EgOeoB+EN0baY22r+c=; b=X9dXupAN
JWv37CH7B4DOgKkX5p4Zrs8u+S3oCMssuEJLjGgid6YJGvipq61vapH6H8waBygR
WkuxGD3aqvU6U5AjalTwBN1Unfxz2bAZyQ+106x8AQbMCToaJTJP2SOe3G9FjqR3
oLEfT8nnYg47EM7IcVTMb7tuQUycC6qhGXlLaBVhh4M2opnQ1UFVcCqDAL85jGQ9
MKpYHYhFNHpGCTA1iOVbO7hcRmWvFZhMtNXQcGlixxziNKZLGCFEEx5LcA/ofepT
L94EdTvEy9IGyngt0Xu7T3gRV6gxOTYf5bkRwvDSP37gASGOzQeTOislS9lMPt2R
k+JZ7Z6EyEpU8g==
X-ME-Sender: <xms:PxIrYiBaVGITs9L219ffzS1S7pBc9vLavNXNC4rFI7TFEim7aT9Shg>
<xme:PxIrYsg7WcSWXkgA3s6i9GKDFhD0KpKlL41MB2ttx3pzifRR6jVzFwLh28Sy9aZra
H6m8HbrIcqP>
X-ME-Received: <xmr:PxIrYll8dEl2MqDRKY8sCGpGZoJ57kDkPfHzCJOfoisHB4ejfawQ-xnG9Q2cr8wcgdKjLVUQxcV7xhF2QB934ACORTgNCkr0a5DtGKKVkBAQ4nc>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddruddvuddguddviecutefuodetggdotefrod
ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesth
ejredttdefjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghnuceorhhovghlsehr
ohgvlhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrhhnpeetueejffetud
efieetvefhgfetvdegieejkeejuedtvefhvedvudeutdetteduieenucevlhhushhtvghr
ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlhesrhhovghlshgthh
hrohgvvhgvnhdrnhgvth
X-ME-Proxy: <xmx:PxIrYgxUQAPVZ-f0BIwOm_rnJR8Uk26grDM8YRBhTfBVni8MMqcppA>
<xmx:PxIrYnRVOk13ir2DMPbISEt3sL6DdHp-muIIH69yLooRKvUraldG7g>
<xmx:PxIrYrY2cyowyz_jWCd57pXnI1SXNVHyLbzZfFmYzjFqJc6e4PBXvg>
<xmx:PxIrYqMfTge-UUgtxaoOf06b_3DlfG2bsJJtmASKYjvbWm-UmJQW9g>
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: nl
In-Reply-To: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <33e51b22-3d1e-7c17-7aac-385294712120@roelschroeven.net>
X-Mailman-Original-References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
 by: Roel Schroeven - Fri, 11 Mar 2022 09:11 UTC

Op 10/03/2022 om 13:16 schreef Loris Bennett:
> Hi,
>
> I have a command which produces output like the
> following:
>
> Job ID: 9431211
> Cluster: curta
> User/Group: build/staff
> State: COMPLETED (exit code 0)
> Nodes: 1
> Cores per node: 8
> CPU Utilized: 01:30:53
> CPU Efficiency: 83.63% of 01:48:40 core-walltime
> Job Wall-clock time: 00:13:35
> Memory Utilized: 6.45 GB
> Memory Efficiency: 80.68% of 8.00 GB
>
> I want to parse this and am using subprocess.Popen and accessing the
> contents via Popen.stdout. However, for testing purposes I want to save
> various possible outputs of the command as text files and use those as
> inputs.
>
> What format should I use to pass data to the actual parsing function?
>
Is this a command you run, produces that output, and then stops (as
opposed to a long-running program that from time to time generates a
bunch of output)?
Because in that case I would use subprocess.run() with
capture_output=True instead of subprocess.Popen(). subprocess.run()
returns a CompletedProcess instance wich has stdout and stderr members
that contain the captured output as byte sequences or strings, depending
on the parameters you passed.

So in your case I would simply read the content of each text file as a
whole into a string, and use subprocess.run() to get the command's
output also as a string. Then you can have a parse function that accepts
such strings, and works exactly the same for the text files as for the
command output. Your parse function can then use splitlines() to access
the lines individually. The data size is very small so it's not a
problem to have it all in memory at the same time (i.e. no need to worry
about trying to stream it instead).

--
"Don't Panic."
-- Douglas Adams, The Hitchhiker's Guide to the Galaxy

Re: How to test input via subprocess.Popen with data from file

<mailman.273.1646991048.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17470&group=comp.lang.python#17470

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: roe...@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: How to test input via subprocess.Popen with data from file
Date: Fri, 11 Mar 2022 10:30:44 +0100
Lines: 75
Message-ID: <mailman.273.1646991048.2329.python-list@python.org>
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<33e51b22-3d1e-7c17-7aac-385294712120@roelschroeven.net>
<43e8e4dd-aa45-94db-9307-7d6219de04d2@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de vsQCXDdYXrPWg0uGM94WJQQ5QgAbCi+/8S1WXbc9tmYQ==
Return-Path: <roel@roelschroeven.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=roelschroeven.net header.i=@roelschroeven.net
header.b=fkxmilAS; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'stream':
0.04; 'bunch': 0.05; 'cpu': 0.07; 'byte': 0.09; 'example:': 0.09;
'parse': 0.09; 'roel': 0.09; 'skip:\xc2 20': 0.09; 'string,':
0.09; 'subject:test': 0.09; 'import': 0.15; 'memory': 0.15;
'captured': 0.16; 'generates': 0.16; 'instance': 0.16; 'key,':
0.16; 'long-running': 0.16; 'outputs': 0.16; 'parsing': 0.16;
'passed.': 0.16; 'planet': 0.16; 'received:10.202': 0.16;
'received:10.202.2': 0.16; 'received:10.202.2.163': 0.16;
'received:64.147': 0.16; 'received:64.147.123': 0.16;
'received:64.147.123.24': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16;
'received:wout1-smtp.messagingengine.com': 0.16; 'run,': 0.16;
'schreef': 0.16; 'stdout': 0.16; 'strings,': 0.16; 'problem':
0.16; 'instead': 0.17; 'to:addr:python-list': 0.20; 'machine':
0.22; 'purposes': 0.22; 'returns': 0.22; 'subject:file': 0.22;
'code': 0.23; 'command': 0.23; 'lines': 0.23; 'skip:p 30': 0.23;
'subject:How': 0.23; 'actual': 0.25; 'function': 0.27; 'output':
0.28; 'header:User-Agent:1': 0.30; 'whole': 0.30; 'program': 0.31;
'(as': 0.32; 'amounts': 0.32; 'same': 0.34; 'header:In-Reply-
To:1': 0.34; 'trying': 0.35; 'files': 0.36; 'those': 0.36;
'subject:from': 0.37; 'using': 0.37; "it's": 0.37; 'file': 0.38;
'read': 0.38; 'thanks': 0.38; 'text': 0.39; 'use': 0.39; 'want':
0.40; 'should': 0.40; 'skip:\xc2 10': 0.62; 'format': 0.62;
'ever': 0.63; 'simply': 0.63; 'pass': 0.64; 'skip:r 20': 0.64;
'accessing': 0.64; 'your': 0.64; 'skip:e 20': 0.67; 'received:64':
0.67; 'per': 0.68; 'exactly': 0.68; 'following:': 0.69;
'subject:skip:s 10': 0.69; 'depending': 0.70; 'content': 0.72;
'yourself': 0.75; '8bit%:100': 0.76; 'produces': 0.76; 'life':
0.77; 'time:': 0.81; 'remind': 0.84; 'film': 0.91; 'organic':
0.91; 'earth': 0.93; 'worry': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:date:date:from:from:in-reply-to:in-reply-to:message-id
:mime-version:references:reply-to:sender:subject:subject:to:to;
s=fm3; bh=zFAW2r5N58Wmfi9374xeGzjdHxvmJJ9YtDd/aoGgwOM=; b=fkxmi
lASDp3IBZI+GUQSmalIFmQIWKDAga7qYeuZOA2EtensOhkrEhqdkQTkpmCp3dXWI
USelamFiZ1NbAr78LbfTN/D93lJQ29Jpa6DiEet8dx3l0aFyc1fFm/bl86THO8dz
Ye8sXN5xclcSjcqPF1X/pjlQu80X0fbNw2qKDosUwiANuNmiOfH2A9VNfSAsqYlk
loNHWLJ8aHWec3IhXnnw1/NuUcFvwDrmCJwbhx72HQ3rQh4TnO4v7Vn9UDTdZzMc
nLu8v5O0wfd2GRyIeiA9MB1ToxAsyRrQXiW0383szCdJM6rQElCcyaeYT5CkwJGE
CGdO6MyX3i2EHll6w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:date:date:from:from:in-reply-to:in-reply-to:message-id
:mime-version:references:reply-to:sender:subject:subject:to:to
:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
fm2; bh=zFAW2r5N58Wmfi9374xeGzjdHxvmJJ9YtDd/aoGgwOM=; b=B4w7GQK4
KYi84bkf2sWrppSbvxekDOyZ5m9MPqZ8Hov1TC7dNGZMkNuJZ1RWlzIQz8RYLr2T
M39JINtWlesd7w7b+2aIG7G78tMXSaQ9eNXvXI1bb3SntrmENG4+6ve6wufnt2lk
tEK9k4JNnxn3a9yIdTyqaaQCsch0hO7HQDayM7PzkbmWxH0U670D4ugM32rwva4Q
wcQD13UJtkZQb+GZeumabXOyI34Agu5YbZrrQISHDJlxUKF6IfqEsQ+LWM6pedaP
AkT4IeSwbFM30mlSepvwBkrPBdzOtDFSrtSF5iWmFF1O7wsSj5R5lc2jmkFpwjdS
SFWDsnD27IYYQA==
X-ME-Sender: <xms:xRYrYiL_3fcW2VzM26umW9FG8zZQse2Sn9fr3KuA2qG6N1xW38SW0w>
<xme:xRYrYqJJDPT_pA4NICZ6BsPl6qLRpoHQZ95HlPiL2Vr8lkALektCag3AXdUkMMPbC
Hv-JoY4_q3_>
X-ME-Received: <xmr:xRYrYis-G0g-PRFscy9pz_joFF_Rxt_rJvg-mLVND7ih2O1oHEj5qN2YhINrTpU4eCMCRBRcfXIivc9YiwamfBMv_hN96a97LHjb3Hl3vTx_kQs>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddruddvvddgtdduucetufdoteggodetrfdotf
fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtke
ertddtfeejnecuhfhrohhmpeftohgvlhcuufgthhhrohgvvhgvnhcuoehrohgvlhesrhho
vghlshgthhhrohgvvhgvnhdrnhgvtheqnecuggftrfgrthhtvghrnheptddtgfeiiefhhe
ehfffftddtgfegvdegleegfedviefhkedtffdvgeefhffhtdfgnecuvehluhhsthgvrhfu
ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhovghlsehrohgvlhhstghhrh
hovghvvghnrdhnvght
X-ME-Proxy: <xmx:xRYrYnaG-wvruTUOSybVSu4avvLQP900wec1hsspqV2Ue96kJa1eGQ>
<xmx:xRYrYpYI8plW45QR7n65K5oZJbf6_-EvxtqdnNJf_RZVXsWqUE6Vpw>
<xmx:xRYrYjAI834sr0wfNrz6cnmpnikCbQ7HIoZp7RPjmnFE2Wlt41bQCg>
<xmx:xRYrYr1Of8ll11Krr0m8DipPwsnlnTiavTswD9R6BbNKIIzKF7lvhA>
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: nl
In-Reply-To: <33e51b22-3d1e-7c17-7aac-385294712120@roelschroeven.net>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <43e8e4dd-aa45-94db-9307-7d6219de04d2@roelschroeven.net>
X-Mailman-Original-References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
<33e51b22-3d1e-7c17-7aac-385294712120@roelschroeven.net>
 by: Roel Schroeven - Fri, 11 Mar 2022 09:30 UTC

Op 11/03/2022 om 10:11 schreef Roel Schroeven:
> Op 10/03/2022 om 13:16 schreef Loris Bennett:
>> Hi,
>>
>> I have a command which produces output like the
>> following:
>>
>>    Job ID: 9431211
>>    Cluster: curta
>>    User/Group: build/staff
>>    State: COMPLETED (exit code 0)
>>    Nodes: 1
>>    Cores per node: 8
>>    CPU Utilized: 01:30:53
>>    CPU Efficiency: 83.63% of 01:48:40 core-walltime
>>    Job Wall-clock time: 00:13:35
>>    Memory Utilized: 6.45 GB
>>    Memory Efficiency: 80.68% of 8.00 GB
>>
>> I want to parse this and am using subprocess.Popen and accessing the
>> contents via Popen.stdout.  However, for testing purposes I want to save
>> various possible outputs of the command as text files and use those as
>> inputs.
>>
>> What format should I use to pass data to the actual parsing function?
>>
> Is this a command you run, produces that output, and then stops (as
> opposed to a long-running program that from time to time generates a
> bunch of output)?
> Because in that case I would use subprocess.run() with
> capture_output=True instead of subprocess.Popen(). subprocess.run()
> returns a CompletedProcess instance wich has stdout and stderr members
> that contain the captured output as byte sequences or strings,
> depending on the parameters you passed.
>
> So in your case I would simply read the content of each text file as a
> whole into a string, and use subprocess.run() to get the command's
> output also as a string. Then you can have a parse function that
> accepts such strings, and works exactly the same for the text files as
> for the command output. Your parse function can then use splitlines()
> to access the lines individually. The data size is very small so it's
> not a problem to have it all in memory at the same time (i.e. no need
> to worry about trying to stream it instead).
>
Very simple example:

    import subprocess
    from pprint import pprint

    def parse(state_data):
        lines = state_data.splitlines(keepends=False)
        state_dict = {}
        for line in lines:
            key, value = line.split(': ')
            state_dict[key] = value
        return state_dict

    def read_from_command():
        return subprocess.run(['./jobstate'], capture_output=True,
check=True, encoding='UTF-8').stdout

    def read_from_file(fn):
        with open(fn, 'rt', encoding='UTF-8') as f:
            return f.read()

    pprint(parse(read_from_command()))
    pprint(parse(read_from_file('jobfile')))

--
"Iceland is the place you go to remind yourself that planet Earth is a
machine... and that all organic life that has ever existed amounts to a greasy
film that has survived on the exterior of that machine thanks to furious
improvisation."
-- Sam Hughes, Ra

Re: How to test input via subprocess.Popen with data from file

<fdca72a1-a8be-438e-921d-5c9ac5cfa5cfn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17472&group=comp.lang.python#17472

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ad4:5b86:0:b0:43a:5c52:30bf with SMTP id 6-20020ad45b86000000b0043a5c5230bfmr2402166qvp.22.1646992509129;
Fri, 11 Mar 2022 01:55:09 -0800 (PST)
X-Received: by 2002:ad4:5d68:0:b0:435:4dbb:d972 with SMTP id
fn8-20020ad45d68000000b004354dbbd972mr7056976qvb.55.1646992509010; Fri, 11
Mar 2022 01:55:09 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Fri, 11 Mar 2022 01:55:08 -0800 (PST)
In-Reply-To: <mailman.273.1646991048.2329.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=183.82.119.180; posting-account=krDOfgoAAACPRuGkCcQsTfFxwLsD6InU
NNTP-Posting-Host: 183.82.119.180
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de> <43e8e4dd-aa45-94db-9307-7d6219de04d2@roelschroeven.net>
<33e51b22-3d1e-7c17-7aac-385294712120@roelschroeven.net> <mailman.273.1646991048.2329.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fdca72a1-a8be-438e-921d-5c9ac5cfa5cfn@googlegroups.com>
Subject: Re: How to test input via subprocess.Popen with data from file
From: bhav...@techlearn.live (Bhavesh Kunar)
Injection-Date: Fri, 11 Mar 2022 09:55:09 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 115
 by: Bhavesh Kunar - Fri, 11 Mar 2022 09:55 UTC

On Friday, 11 March 2022 at 15:01:43 UTC+5:30, Roel Schroeven wrote:
> Op 11/03/2022 om 10:11 schreef Roel Schroeven:
> > Op 10/03/2022 om 13:16 schreef Loris Bennett:
> >> Hi,
> >>
> >> I have a command which produces output like the
> >> following:
> >>
> >> Job ID: 9431211
> >> Cluster: curta
> >> User/Group: build/staff
> >> State: COMPLETED (exit code 0)
> >> Nodes: 1
> >> Cores per node: 8
> >> CPU Utilized: 01:30:53
> >> CPU Efficiency: 83.63% of 01:48:40 core-walltime
> >> Job Wall-clock time: 00:13:35
> >> Memory Utilized: 6.45 GB
> >> Memory Efficiency: 80.68% of 8.00 GB
> >>
> >> I want to parse this and am using subprocess.Popen and accessing the
> >> contents via Popen.stdout. However, for testing purposes I want to save
> >> various possible outputs of the command as text files and use those as
> >> inputs.
> >>
> >> What format should I use to pass data to the actual parsing function?
> >>
> > Is this a command you run, produces that output, and then stops (as
> > opposed to a long-running program that from time to time generates a
> > bunch of output)?
> > Because in that case I would use subprocess.run() with
> > capture_output=True instead of subprocess.Popen(). subprocess.run()
> > returns a CompletedProcess instance wich has stdout and stderr members
> > that contain the captured output as byte sequences or strings,
> > depending on the parameters you passed.
> >
> > So in your case I would simply read the content of each text file as a
> > whole into a string, and use subprocess.run() to get the command's
> > output also as a string. Then you can have a parse function that
> > accepts such strings, and works exactly the same for the text files as
> > for the command output. Your parse function can then use splitlines()
> > to access the lines individually. The data size is very small so it's
> > not a problem to have it all in memory at the same time (i.e. no need
> > to worry about trying to stream it instead).
> >
> Very simple example:
>
> import subprocess
> from pprint import pprint
>
> def parse(state_data):
> lines = state_data.splitlines(keepends=False)
> state_dict = {}
> for line in lines:
> key, value = line.split(': ')
> state_dict[key] = value
> return state_dict
>
> def read_from_command():
> return subprocess.run(['./jobstate'], capture_output=True,
> check=True, encoding='UTF-8').stdout
>
> def read_from_file(fn):
> with open(fn, 'rt', encoding='UTF-8') as f:
> return f.read()
>
> pprint(parse(read_from_command()))
> pprint(parse(read_from_file('jobfile')))
>
> --
> "Iceland is the place you go to remind yourself that planet Earth is a
> machine... and that all organic life that has ever existed amounts to a greasy
> film that has survived on the exterior of that machine thanks to furious
> improvisation."
> -- Sam Hughes, Ra

------------------------------------------------------------------------------------------------------------------------------------
Want to learn how self-driving cars work and how the future is being built today using AI?
Understand the tech behind the 'Tesla Auto Pilot'.

Get Enrolled Today - https://bit.ly/3hUIKuy

What you’ll learn in this session?
- What is an autopilot?
- What are the features of autopilot?
- What is computer vision?
- Computer vision applications
- What is YOLO(You only look once)?
- What is Deep Learning?
- Deep Learning applications

Get Practice Material - You will get Notebook to revise, practice, test yourself and interact with mentor.
Earn a Certificate upon completion of Course

Book your session today for How Tesla Self Driving Car Work
Last date is Mar 14, 2022 | 2:00 PM

Re: How to test input via subprocess.Popen with data from file

<t0g1e0$et4$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17475&group=comp.lang.python#17475

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!i2H2dPTP1PDAFtyjvKGI8g.user.46.165.242.75.POSTED!not-for-mail
From: tob...@tobiah.org (Tobiah)
Newsgroups: comp.lang.python
Subject: Re: How to test input via subprocess.Popen with data from file
Date: Fri, 11 Mar 2022 09:38:07 -0800
Organization: Aioe.org NNTP Server
Message-ID: <t0g1e0$et4$1@gioia.aioe.org>
References: <878rtiq9ys.fsf@hornfels.zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="15268"; posting-host="i2H2dPTP1PDAFtyjvKGI8g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Tobiah - Fri, 11 Mar 2022 17:38 UTC

Why not just have scripts that echo out the various sets of test
data you are interested in? That way, Popen would
always be your interface and you wouldn't have to
make two cases in the consumer script.

In other words, make program that outputs test
data just like your main data source program.
Then the consumer would only have to work in one way.

On 3/10/22 04:16, Loris Bennett wrote:
> Hi,
>
> I have a command which produces output like the
> following:
>
> Job ID: 9431211
> Cluster: curta
> User/Group: build/staff
> State: COMPLETED (exit code 0)
> Nodes: 1
> Cores per node: 8
> CPU Utilized: 01:30:53
> CPU Efficiency: 83.63% of 01:48:40 core-walltime
> Job Wall-clock time: 00:13:35
> Memory Utilized: 6.45 GB
> Memory Efficiency: 80.68% of 8.00 GB
>
> I want to parse this and am using subprocess.Popen and accessing the
> contents via Popen.stdout. However, for testing purposes I want to save
> various possible outputs of the command as text files and use those as
> inputs.
>
> What format should I use to pass data to the actual parsing function?
>
> I could in both production and test convert the entire input to a string
> and pass the string to the parsing method.
>
> However, I could use something like
>
> test_input_01 = subprocess.Popen(
> ["cat test_input_01.txt"],
> stdout=subprocess.PIPE,
> )
>
> for the test input and then pass a Popen object to the parsing function.
>
> Any comments on these alternative or suggestions for doing something
> completely different?
>
> Cheers,
>
> Loris
>

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor