\x03 it goes to a new line and continues to output?
On Tue, Dec 27, 2016 at 7:46 PM, David Rock wrote:
> * Alan Gauld via Tutor [2016-12-28 00:40]:
> > On 27/12/16 19:44, richard kappler wrote:
> > > Using python 2.7 - I have a large log file we recorded of streamed xml
> dat
e fact that 'events' span multiple lines is
challenging me.
On Tue, Dec 27, 2016 at 3:55 PM, David Rock wrote:
> * richard kappler [2016-12-27 15:39]:
> > I was actually working somewhat in that direction while I waited. I had
> in
> > mind to use something along the l
f2.write(line1)
line1 = ""
but that didn't work. It neither broke each line on etx (multiple events
with stx and etx on one line) nor did it concatenate the multi-line events.
On Tue, Dec 27, 2016 at 3:25 PM, David Rock wrote:
> * richard kappler [2016-1
Using python 2.7 - I have a large log file we recorded of streamed xml data
that I now need to feed into another app for stress testing. The problem is
the data comes in 2 formats.
1. each 'event' is a full set of xml data with opening and closing tags +
x02 and x03 (stx and etx)
2. some events h
I have a two script test env set to simulate a controller in production.
The controller creates xml data from a camera tunnel as packages roll
through it, sends these xml messages over tcp to a different machine.
To simulate this in our test environment, I take a log of all the xml
messages, read
On Fri, Feb 12, 2016 at 2:23 AM, Ian Winstanley
wrote:
> To refer to a class variable you need to put the class name first for
> example MyClass.xslt
>
That indeed did the trick, thanks Ian.
regards, Richard
--
*Java is like Alzheimers; it starts slow and eventually, it takes away all
of you
Thanks for the reply Martin, and in this instance I cannot post the actual
code (company rules). What I can do is say that with the xslt variable
defined within the formatter method, everything works, but when I pull it
out and put it in the upper level of the class, it gives me a traceback
that sa
Trying to optimize the modular input we wrote for Splunk, the basic
structure (dictated by Splunk) is the entire script is a class with
numerous methods within. The modular input reads a tcp stream, starts a new
thread for each source, reads the messages from that source into a buffer,
checks for s
Ah, I see, makes perfect sense now that it's right under my nose. Thanks
Peter!
regards, Richard
On Fri, Feb 5, 2016 at 12:04 PM, Peter Otten <__pete...@web.de> wrote:
> richard kappler wrote:
>
> > I have a script that checks a file and if there are new additions to t
I have a script that checks a file and if there are new additions to the
file, parses and sends the new additions. This log rolls over and zips at
midnight creating a new log of the same name. The problem is, when the file
rolls over, the new file seems to follow the old file the way the script is
On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson wrote:
>
> Just a few followup remarks:
>
> This is all Python 3, where bytes and strings are cleanly separated.
> You've got a binary stream with binary delimiters, so we're reading binary
> data and returning the binary XML in between. We separate
Hi Sarah!
instead of 'python hello.py', try
>>>import hello.py
using python hello.py works from the Linux command line (presumably Windows
as well) and it starts python then runs the hello.py script. From within
the python interpreter, you import the file and it executes.
HTH, Richard
On Thu,
This is a continuation of the thread 'reading an input stream' I had to
walk away from for a few days due to the holidays and then other work
considerations, and I figured it best to break my confusion into separate
chunks, I hope that's appropriate. In short, my script needs to read a
stream of xm
This is a continuation of the thread 'reading an input stream' I had to
walk away from for a few days due to the holidays and then other work
considerations, and I figured it best to break my confusion into separate
chunks, I hope that's appropriate. In short, my script needs to read a
stream of xm
This is a continuation of the thread 'reading an input stream' I had to
walk away from for a few days due to the holidays and then other work
considerations, and I figured it best to break my confusion into separate
chunks, I hope that's appropriate. In short, my script needs to read a
stream of xm
This is a continuation of the thread 'reading an input stream' I had to
walk away from for a few days due to the holidays and then other work
considerations, and I figured it best to break my confusion into separate
chunks, I hope that's appropriate. In short, my script needs to read a
stream of xm
Sorry it took so long to respond, just getting back from the holidays. You
all have given me much to think about. I've read all the messages through
once, now I need to go trough them again and try to apply the ideas. I'll
be posting other questions as I run into problems. BTW, Danny, best
explanat
I have to create a script that reads xml data over a tcp socket, parses it
and outputs it to console. Not so bad, most of which I already know how to
do. I know how to set up the socket, though I am using a file for
development and testing, am using lxml and have created an xslt that does
what I w
I need to write a script that runs ssh-copy-id to over 500 clients from one
master (setting up keys to use ansible).
I understand how to get my script to read each IP address in a list, use it
as input and then move on to the next, but not sure how to handle the
password feed, particularly as ther
I have an xml file that get's written to as events occur. Each event writes
a new 'line' of xml to the file, in a specific format, eg: sometthing like
this:
http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="Logging.xsd" version="1.0">somestuff
and each 'line' has that sam
to
re-read the tutorials and examples, thank you.
regards, Richard
On Tue, Oct 27, 2015 at 1:44 PM, Alan Gauld
wrote:
> On 27/10/15 14:52, richard kappler wrote:
>
> In our test environment we have simulated this by building three vm's. VM1
>> has a python script that sends raw da
I'm having difficulty wrapping my arms around sockets and threading, not so
much from a 10,000 foot/ network perspective, but from a low level
perspective.
In our production environment we have three machines that generate data and
forward it over tcp to a computer that stores the data, parses it
>
>
>
> how else do you skip the current line if the 'try' can't be done, and go on
>> to the next line exiting the program with a trace error?
>>
>
> That last sentence confused me. If you use pass (or continue)
> you will NOT get any trace error. If you want to store the
> error to report it at t
I'm reading up on exception handling, and am a little confused. If you have
an exception that just has 'pass' in it, for example in a 'for line in
file:' iteration, what happens? Does the program just go to the next line?
EX:
for line in file:
try:
do something
except:
pas
>
> Hi Richard,
>
> Just to check: what operating system are you running your program in?
> Also, what version of Python?
>
Hi Danny, using Linux and Python 2.7
>
>
>
> ##
> with open('input/test.xml', 'rU') as f1: ...
> ##
>
>
> Question: c
>
>>
> Reread my original post and you'll see that your "s" isn't set the same
> way mine was
No. My implementation of your code:
#!/usr/bin/env python
with open('input/PS06Test_100Packages.xml', 'r') as f1:
with open('mod1.xml', 'a') as f2:
for line in f1:
s = '\x02' +
>
>
>
> > That is *very* unlikely.
>
Perhaps, but I assure you it is what is happening.
>
> > Verify that you deleted the existing mod1.xml. As you open the file in
> > append mode existing faulty lines persist.
>
I did, hence the above assurance.
Here's the modified code:
#!/usr/bin/env pyth
Thanks for the reply Mark, tried that, same result.
On Tue, Sep 22, 2015 at 8:58 AM, Mark Lawrence
wrote:
> On 22/09/2015 13:37, richard kappler wrote:
>
>> I have a file with several lines. I need to prepend each line with \x02
>> and
>> append each line with \x03 fo
I have a file with several lines. I need to prepend each line with \x02 and
append each line with \x03 for reading into Splunk. I can get the \x02 at
the beginning of each line, no problem, but can't get the \x03 to go on the
end of the line. Instead it goes to the beginning of the next line.
I ha
Nevermind, figured it out. it needed to be delay = 0 and delay = 0.5, not ==
regards, Richard the virus ridden
On Wed, Sep 16, 2015 at 1:03 PM, richard kappler
wrote:
> Missing something obvious here, but down with the flu so I'm foggy and
> just can't see it. I need to set a
Missing something obvious here, but down with the flu so I'm foggy and just
can't see it. I need to set a variable 'delay' to be used in
time.sleep(delay) later on in a script, based on user input. Something odd
is going on in setting the variable though. Here's the snippet where I'm
trying to set
Thanks for all the assistance, turned out it was a problem with the
iptables not having an accept for eth1. Onward and upward!
regards, Richard
On Sat, Sep 12, 2015 at 12:24 PM, Martin A. Brown
wrote:
>
> Hello and good morning
>
> I may be mistaken, but it looks like you are trying to open the
Still working on my data feed script, if you'll recall from previous
emails, it reads incoming data and creates a name for image files based on
the incoming data in a test environment. below is a snippet of that code
that copies the next image in the pool renaming it as it copies, sends to
another
I try to
send a file it goes bollocks up. Still need ideas.
regards, Richard
On Fri, Sep 11, 2015 at 12:17 PM, richard kappler
wrote:
> Figured it out. On the receiving machine I had to
>
> # modprobe ip_conntrack_ftp
>
>
> On Fri, Sep 11, 2015 at 12:00 PM, richard kappler
&g
Figured it out. On the receiving machine I had to
# modprobe ip_conntrack_ftp
On Fri, Sep 11, 2015 at 12:00 PM, richard kappler
wrote:
> I can connect via ftp, but when I try to send a file, I get a no route to
> host error, I don't understand.
>
> code:
>
> >&
I can connect via ftp, but when I try to send a file, I get a no route to
host error, I don't understand.
code:
>>> import ftplib
>>> from ftplib import FTP
>>> fBOT = FTP()
>>> oldfile = '/home/test/DataFeed/input/images/BOT/1.jpg'
>>> newfile = 'new.jpg'
>>> oldfile = open('/home/test/DataFeed/
Here's my code, no tabs were used, all whitespace verified made with
spacebar:
print("Please enter a number for feed speed...")
print("1 - Batch")
print("2 - 2 per second")
print("3 - Real Time")
print("4 - Exit")
if x == ord('1'):
delay = 0
elif x == ord('2'):
delay = 0.5
elif x == ord('
Thanks, tried them both, both work great on Linux. Now I understand better.
regards, Richard
On Wed, Sep 9, 2015 at 11:28 AM, Laura Creighton wrote:
> >I did a little experiment:
> >
> f1 = open("output/test.log", 'a')
> f1.write("this is a test")
> f1.write("this is a test")
> >
Albert-Jan, thanks for the response. shutil.copyfile does seem to be one of
the tools I need to make the copying, renaming the copy and saving it
elsewhere in one line instead of three or more.
Still not sure how to efficiently get the script to keep moving to the next
file in the directory though
Under a different subject line (More Pythonic?) Steven D'Aprano commented:
> And this will repeatedly open the file, append one line, then close it
> again. Almost certainly not what you want -- it's wasteful and
> potentially expensive.
And I get that. It does bring up another question though. W
e other than to say it's not reading from stdin,
but from a log file to simulate stdin in a test environment.
regards, Richard
On Wed, Sep 9, 2015 at 9:37 AM, Peter Otten <__pete...@web.de> wrote:
> richard kappler wrote:
>
> > Would either or both of these wo
> It looks likes I was not clear enough: XML doesn't have the concept of lines.
When you process XML "by line" you have buggy code.
No Peter, I'm pretty sure it was I who was less than clear. The xml data is
generated by events, one line in a log for each event, so while xml doesn't
have the conce
Yes, many questions today. I'm working on a data feed script that feeds
'events' into our test environment. In production, we monitor a camera that
captures an image as product passes by, gathers information such as
barcodes and package ID from the image, and then sends out the data as a
line of xm
Would either or both of these work, if both, which is the better or more
Pythonic way to do it, and why?
###
import whatIsNeeded
writefile = open("writefile", 'a')
with open(readfile, 'r') as f:
for line in f:
if keyword in line:
do stuff
> Do you want to find just the second occurence in the *file* or the second
occurence within a given tag in the file (and there could be multiple such
tags)?
There are multiple objectdata lines in the file and I wish to find the
second occurence of timestamp in each of those lines.
> Is objectdat
I need to find the index of the second occurance of a string in an xml file
for parsing. I understand re well enough to do what I want to do on the
first instance, but despite many Google searches have yet to find something
to get the index of the second instance, because split won't really work on
Running python 2.7 on Linux
While for and if loops always seem to give me trouble. They seem obvious
but I often don't get the result I expect and I struggle to figure out why.
Appended below is a partial script. Ultimately, this script will read a
log, parse out two times from each line of the lo
SOLVED: Sometimes one just has to be an idiot. One must remember that
computers count from zero, not from one. Changes my list indexes to reflect
that small but crucial fundamental point, and all worked fine.
regards, Richard
On Wed, Jun 3, 2015 at 10:37 PM, richard kappler
wrote:
> Figu
Figured out the string delimiters problem, thanks for all the help. Now
I've run into another.
I've used the re.finditer that I think it was Peter suggested. So I have:
for line in file:
s = line
t = [m.start() for m in re.finditer(r"]", s)]
q = len(t)
which w
Perhaps the better way for me to have asked this question would have been:
How can I find the location within a string of every instance of a
character such as ']'?
regards, Richard
On Wed, Jun 3, 2015 at 5:16 PM, Alex Kleider wrote:
> On 2015-06-03 12:53, Alan Gauld wrote:
> ...
>
>> If this
I'm eager for direction. What other information would better help
explain?
regards, Richard
On Wed, Jun 3, 2015 at 4:31 PM, Alan Gauld
wrote:
> On 03/06/15 21:23, richard kappler wrote:
>
>> hold the phone
>>
>> I have no idea why it worked, would love an expl
lse
executes so both types of lines format correctly except for the multiple
identifiers in the non-icdm lines
I could still use some help with that bit, please.
regards, Richard
On Wed, Jun 3, 2015 at 4:13 PM, richard kappler
wrote:
> I was trying to keep it simple, you'd think by now
w to handle the differences in the end of the
non-icdm files (potentially more than identifier ] delimited as described
above).
regards, Richard
On Wed, Jun 3, 2015 at 3:53 PM, Alan Gauld
wrote:
> On 03/06/15 20:10, richard kappler wrote:
>
>> for formatting a string and adding de
for formatting a string and adding descriptors:
test = 'datetimepart1part2part3the_rest'
newtest = 'date=' + test[0:4] + ' time=' + test[4:8] + ' part1=' +
test[8:13] + ' part2=' + test[13:18] + ' part3=' + test[18:23] + ' the
rest=' + test[23:]
and while this may be ugly, it does what I want it
ectory, it works fine,
does exactly what I expected it to do (ie. opens the files).
I thought it might be because because I used Doc... instead of ~/Doc... for
my path, but I got the same traceback.
curiouser and curiouser was, Richard
On Thu, May 28, 2015 at 3:01 PM, Felix Dietrich <
felix.dietr
;r') % (rd1)
or
file = os.path.open(rd1, 'r')
or do I not need os.path...
Kind of lost in the woods here.
regards, Richard
On Thu, May 28, 2015 at 1:56 PM, Alan Gauld
wrote:
> On 28/05/15 18:39, richard kappler wrote:
>
> I've created a config file which the user wo
This is a continuation of the read data script I asked for help on
yesterday, which works very well thanks to all the help from the list.
My script opens and reads in new lines from an in service log file,
extracts specific data, writes it to another file for analysis. All of that
works fine, test
n off and on as a hobby for about 4-5
years, learning what I need to know to do what I want to do, but I just
took a new job and part of it requires ramping up my Python knowledge as
I'm the only Python (and Linux) guy here.
On Wed, May 27, 2015 at 09:26:15AM -0400, richard kappler wrote:
I'm writing a script that reads from an in-service log file in xml format
that can grow to a couple gigs in 24 hours, then gets zipped out and
restarts at zero. My script must check to see if new entries have been
made, find specific lines based on 2 different start tags, and from those
lines extra
Would something like
if len(dict) = 8
return d
else
continue
work?
On Sun, Dec 1, 2013 at 8:54 PM, richard kappler wrote:
> Now I'm completely lost. While opening the serial port outside the
> function sounds like a good idea, I'm thinking that might not work unless
3:06 PM, spir wrote:
> On 12/01/2013 08:28 PM, richard kappler wrote:
>
>> I have a script that reads sensor values gathered by an Arduino board from
>> serial as a dictionary, said values to later be used in the AI for Nav &
>> Control. Here's the script:
>
I have a script that reads sensor values gathered by an Arduino board from
serial as a dictionary, said values to later be used in the AI for Nav &
Control. Here's the script:
#!/usr/bin/python
def sensorRead():
import serial
from time import sleep
sensors = {}
sensors = dict.fro
I'm using psutil to generate some somatic data with the following script:
import psutil as ps
cpu = ps.cpu_percent()
mem = ps.virtual_memory()
disk = ps.disk_usage('/')
All works well, but except for cpu I am struggling to learn how to strip
out what I don't need.
For example, once I do the abo
I have a script that makes use of the Google speech recognition API as
follows:
import shlex
print " say something"
os.system('sox -r 16000 -t alsa default recording.flac silence 1 0.1 1% 1
1.5 1%')
cmd='wget -q -U "Mozilla/5.0" --post-file recording.flac
--header="Content-Type: audio/x-flac; rat
On Wed, Feb 13, 2013 at 6:56 PM, Steven D'Aprano wrote:
> On 14/02/13 10:14, richard kappler wrote:
>
>> I have tried to run the Google speech recognition code found here:
>> https://github.com/jeysonmc/**python-google-speech-scripts/**
>> blob/master/stt_google.p
> See that KeyboardInterrupt line? That was missing from your first post.
>
> You get that because you have hit Ctrl-C, which is Python's way of halting
> the running code (if possible). If you don't want this exception, then
> don't hit Ctrl-C.
>
> Which of course brings you to a dilemma -- the so
I have tried to run the Google speech recognition code found here:
https://github.com/jeysonmc/python-google-speech-scripts/blob/master/stt_google.py
I am getting the following traceback:
Traceback (most recent call last):
File "", line 1, in
File "GoogSTT.py", line 43, in listen_for_speech
Maybe way off scope here, I hope not. I just can't get the accuracy I need
with pocketsphinx at the moment(though I continue to work on it). Google's
webkit-speech actually works pretty durned well, here's an example:
http://slides.html5rocks.com/#speech-input But that doesn't really solve
any pro
I want to be able to communicate between a raspberry pi and a laptop
running ubuntu, transferring text from the pi to the laptop. Specifically
the Pi would be running poscketsphinx speech rec and would send the
generated text through the crossover between the two ethernet ports to a
python program
Before anybody jumps me about this question being inappropriate for this
list, yes, I know it probably is BUT, the two places where it might be
appropriate are down pretty hard, so this is my only option (I think).
The question is in regards to pygtk I think, and pocketsphinx obliquely.
Appended b
Class is still something I struggle with. I think I'm finally starting to
get my head wrapped around it, but the discussion in a different thread has
sparked a question. First, please check my understanding:
A class creates objects, it's like a template that allows me to create as
many copies as I
I have a sort of a dictionary resulting from psutil.disk_usage('/') that
tells me info about my hard drive, specifically:
usage(total=147491323904, used=62555189248, free=77443956736, percent=42.4)
I'm having a bit of a brain fudge here and can't remember how to strip out
what I want. All I want
I'm working through Mark Lutz's "Python," reviewing the section on lists. I
understand the list comprehension so far, but ran into a snag with the
matrix. I've created the matrix M as follows:
M = [[1, 2, 3[, [4, 5, 6], [7, 8, 9]]
then ran through the various comprehension examples, including:
d
Me again. :-)
Today was a good day, I accomplished a lot, but I'm stumbling now. I
assembled the sensor array, coded the Arduino board to read the sensors and
send the data out to serial, played with formatting the data, learned
enough about the python serial library to be a little dangerous.
The
>I didn't really understand the above. Is 'manager' some kind of library?
>
> http://docs.python.org/2/library/multiprocessing.html#managers
>
>
> >Who's Bill? Alan was referring to Twisted that is an event driven
> >framework. Event driven or asynchronous processing is a third option
> >(after thr
I notice no one has mentioned asyncore. Is that something I should stay
away from? I just started digging through the doc file.
regards, Richard
--
quando omni flunkus moritati
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscript
Oscar, that was positively brilliant! Now I get it, I understand how to do
it, and I think this has rearranged my entire plan for the "MCP." If the
MCP is basically just a program that calls several other
programs(processes) and does that bit of coordination between each, then my
life just got meas
To all, especially Dave, Oscar and Ramit, thanks for the discussion and
help. Tino, as soon as I have something to put up, I will gladly put it up
on Github. At the moment I only have a few snippets I've written in trying
to learn the various bits everyone has been helping me with.
Just for the re
Oscar, thanks for the link, though I must say with all due respect, if it
was "obvious" I wouldn't have had to ask the question. Good link though. I
suspect the reason I didn't find it is I did my searches under threading as
opposed to multi-processing.
Dave, no offense taken, great write-up. Now
As I sit through the aftermath of Sandy, I have resumed my personal quest
to learn python. One of the things I am struggling with is running multiple
processes. I read the docs on threading and am completely lost so am
turning to the most excellent tutors here (and thanks for all the help,
past, pr
If I have a variable and send it's value to a function to be modified and
returned, how do I get the function return to replace the original value of
the variable?
Example:
import random
x = 50
def rndDelta(x):
d = random.uniform(-10, 10)
x = x + d
return x
When I call rndDelta, it
Methinks I'm missing something obvious, but can't quite put my finger on
it. If, in the interpreter, I enter the following code:
def hungry(batVolt):
if batVolt >94:
return ("I am not hungry at the moment")
elif 64 < batVolt < 95:
return ("I'm starting to get hungry")
I'm not sure which direction to go. I need to be able to run multiple
?processes? ?threads? (not sure which) concurrently. I'm working on AI for
a robot and because I'm not sure what direction to go I'll use the term
"thread" to illustrate my question, realizing threads may not be what I'm
lookin
The summer of intensive learning continues. Working on subprocess today.
I figured out how to send data out, for example to my festival tts engine:
[code]response = k.respond(input, "richard")
festivalCmd = '(SayText "%s")' % response
subprocess.Popen(['/usr/bin/festival', '-b', festivalCmd])[/c
Starting to work through "Programming Computer Vision with Python" in my
-summer of learning python- quest. As I read through the intro to the PIL
library, I came across the below code. When I read it, I said to my self
"I don't see how that calls a set of files, there's no specificity. How
does
85 matches
Mail list logo