Re: [Tutor] Python Arduino Web Page

2013-08-15 Thread Dave Angel
Engineering wrote:

   

> 
> 

[Tutor] please help with read_until, write script

2013-08-15 Thread cindy chao
Hi, all Python Experts,
I am a Python beginner.
I am trying to script the following steps.
I have problem to match the step after 'signature check?'
'[999.daisyse.07260019]:' the value of 0726009 is dynamic, every time it will 
be different, so I don't know how to do it. 
For sure I have problem to match 'directory and config file? (Yes/No) [Yes]:' 
and 'current configuration? (Yes/No) [Yes]:'
I use IDLE in pc to write and run the script.

Please help, thank you very much.

All the steps I want to script.

vyatta@Daisy-BGP1:~$ add sys image 
http://packages.vyatta.com/vyatta-dev/daisy-se/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso
Trying to fetch ISO file from 
http://packages.vyatta.com/vyatta-dev/daisy-se/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso
  % Total    % Received % Xferd  Average Speed   Time    Time Time  Current
 Dload  Upload   Total   Spent    Left  Speed
100  223M  100  223M    0 0  45.6M  0  0:00:04  0:00:04 --:--:-- 45.2M
ISO download succeeded.
Checking for digital signature file...
  % Total    % Received % Xferd  Average Speed   Time    Time Time  Current
 Dload  Upload   Total   Spent    Left  Speed
  0 0    0 0    0 0  0  0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404
Unable to fetch digital signature file.
Do you want to continue without signature check? (yes/no) [yes] yes
Checking MD5 checksums of files on the ISO image...OK.
Done!
What would you like to name this image? [999.daisyse.07260019]:
OK.  This image will be named: 999.daisyse.07260019
Installing "999.daisyse.07260019" image.
Copying new release files...
Would you like to save the current configuration
directory and config file? (Yes/No) [Yes]: yes
Copying current configuration...
Would you like to save the SSH host keys from your
current configuration? (Yes/No) [Yes]: yes
Copying SSH keys...
Setting up grub configuration...
Done.

=
Here is my code.

session = telnetlib.Telnet("10.1.34.21", timeout=5)
...skip some write and read_until...
session.write('yes'+'\n')
h1=session.read_until('[999.daisyse.07260019]:')
print h1
session.write('\n')
    
#h20=session.read_until('(Yes/No) [Yes]:')- never match
#h20=session.read_until('[Yes]:') - never match
#h20=session.expect('(Yes/No)', '[Yes]:')- script just terminate
#h20=session.read_lazy('[Yes]:')-script just terminate
#h20=session.read_expect('.*\(Yes\/No\)')- script just terminate
h20=session.read_expect('.*\s\(Yes\/No\)')- script just terminate

print h20

===
#h20=session.read_until('(Yes/No) [Yes]:')- never match, just wait there, never 
finish.


OUtput from IDLE:

[Kvyatta@Daisy-BGP1:~$
 add sys image http://packages.vyatta.com/vyatta-dev/daisy-s 
e/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso 

Trying to fetch ISO file from 
http://packages.vyatta.com/vyatta-dev/daisy-se/unstable/iso/livecd_2013-07-26-0018-7e824ac_i386.iso

  % Total    % Received % Xferd  Average Speed   Time    Time Time  Current

 Dload  Upload   Total   Spent    Left  Speed


  0 0    0 0    0 0  0  0 --:--:-- --:--:-- --:--:-- 0
 34  223M   34 77.1M    0 0  87.1M  0  0:00:02 --:--:--  0:00:02 87.4M
 60  223M   60  135M    0 0  71.6M  0  0:00:03  0:00:01  0:00:02 71.8M
 69  223M   69  154M    0 0  53.4M  0  0:00:04  0:00:02  0:00:02 53.5M
 70  223M   70  156M    0 0  19.2M  0  0:00:11  0:00:08  0:00:03 19.2M
100  223M  100  223M    0 0  25.2M  0  0:00:08  0:00:08 --:--:-- 25.2M

ISO download succeeded.

Checking for digital signature file...

  % Total    % Received % Xferd  Average Speed   Time    Time Time  Current

 Dload  Upload   Total   Spent    Left  Speed


  0 0    0 0    0 0  0  0 --:--:-- --:--:-- --:--:-- 0
  0 0    0 0    0 0  0  0 --:--:-- --:--:-- --:--:-- 0

curl: (22) The requested URL returned error: 404

Unable to fetch digital signature file.

Do you want to continue without signature check? (yes/no) [yes]
 yes

Checking MD5 checksums of files on the ISO image...OK.

Done!

What would you like to name this image? [999.daisyse.07260019]:


==


#h20=session.expect('(Yes/No)', '[Yes]')- script just terminate

Do you want to continue without signature check? (yes/no) [yes]
 yes

Checking MD5 checksums of files on the ISO image...OK.

Done!

What would you like to name this image? [999.daisyse.07260019]:
>>> 

===___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python

2013-08-15 Thread Jake Wohldmann
Hello I am a beginner to using any type of script.  How long does it take
to become fluent at a script?  I will only be able to practice python on
weekends since school is starting.  I was also wondering if I could use
python on my android phone.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [Python-Help] Instancing class issue

2013-08-15 Thread Dino Bektešević
Hello,


The name of the variable doesn't matter, that's still what it does; you can
> think of it as encapsulating any other keyword arguments.
>
> >>> def foo(bar, **kwargs):
> ... print("bar: %s" % (bar,))
> ... print("kwargs: %r" % (kwargs,))
> ...
> >>> foo("bar", baz="qux", wibble="wobble")
> bar: bar
> kwargs: {'baz': 'qux', 'wibble': 'wobble'}
>


Yeah so much I figured, same way self could be me, but what kind of
__init__ function is that that doesn't even know how many arguments it
takes, at least it should have the mandatory arguments to satisfy the
Parent __init__ function which is object but I don't even see
object.__init__(self,
**kwargs) in sdsspy's __init__ (or **keys whatever you prefer) what are
even the keyword arguments needed for instancing object. Isn't object like
THE most abstract class that becomes anything? How do I even go about
trying to instance this? (and since it calls on some printed error
obviously written somewhere in the SDSSPY how do I reach it so I'd know
what to do?)

many thanks to responders,
Dino Bektešević

2013/8/12 Chris Down 

> Hi Dino,
>
> On 2013-08-12 20:32, Dino Bektešević wrote:
> > def __init__(self, **keys):
> > from . import util
> >
> > self.keys=keys
> > self.load()
> >
> > where I don't understand what **keys mean, I've only seen that as
> **kwargs
> > meaning other key words and arguments in examples.
>
> The name of the variable doesn't matter, that's still what it does; you can
> think of it as encapsulating any other keyword arguments.
>
> >>> def foo(bar, **kwargs):
> ... print("bar: %s" % (bar,))
> ... print("kwargs: %r" % (kwargs,))
> ...
> >>> foo("bar", baz="qux", wibble="wobble")
> bar: bar
> kwargs: {'baz': 'qux', 'wibble': 'wobble'}
>
>
> > When I try to instance
> > Astrom class by:
> > new=Astrom()
> > I receive a following error:
>
> Sorry, no idea about this bit, I've never used sdsspy. est of luck sorting
> this
> out.
>
> Chris
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Input into lists?

2013-08-15 Thread leam hall
I'm trying to take input from a file (CSV spreadsheet) and use the first
line inputs (header) as the names of lists. So far I'm not successful.   :)

How do I take line_list[0], the result of "line.split(',')" and use it as
the name of a list? Does that make sense?

Thanks!

Leam

-- 
Mind on a Mission 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Color segmentation -Open cv

2013-08-15 Thread Zoya Tavakkoli
Hi every one , could you please give me suggestion and code for color
segmentation via opencv on python?
Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Posting solutions to "homeworky" problems

2013-08-15 Thread leam hall
I've just started some of the Euler stuff. Most of the time I ask for
pointers to the logic needed. I enjoy that much more as hopefully I learn
something.

Leam

-- 
Mind on a Mission 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Simple Python SNMP ping?

2013-08-15 Thread leam hall
Is there a way to do a simple check in Python to see if a remote host is
listening on SNMP port 161/UDP?

Thanks!

Leam

-- 
Mind on a Mission 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Reading a video

2013-08-15 Thread Zoya Tavakkoli
Hi
How can read a video frame by frame in python?

Thanks
Zoya
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Input into lists?

2013-08-15 Thread Alan Gauld

On 13/08/13 16:46, leam hall wrote:

I'm trying to take input from a file (CSV spreadsheet) and use the first
line inputs (header) as the names of lists. So far I'm not successful.   :)


Have you tried the csv module?

Usually you use a dictionary keyed by the first line values though.
But i#'m sure you could tweak it to generate separate lists if thats 
really what you need.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Input into lists?

2013-08-15 Thread Dave Angel
leam hall wrote:

> I'm trying to take input from a file (CSV spreadsheet) and use the first
> line inputs (header) as the names of lists. So far I'm not successful.   :)
>
> How do I take line_list[0], the result of "line.split(',')" and use it as
> the name of a list? Does that make sense?
>

No, it doesn't make sense.  You're trying to define a variable that has
a name determined not by your source, but by a name in line 0 of the csv
file.  How then are you going to use that variable?

There are two possibilities:  Either you actually know those names and
are using them in your code, or the names won't be known till runtime.

If the latter, then make a dictionary of lists,

mydict = {}
for item in line_list:
mydict[item] = []

and then populate those lists from each line of the file.

Now, if you're sure you know what the names are to be, then:

names = mydict["name"]
addresses = mydict["address"]

or whatever.




-- 
DaveA


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python

2013-08-15 Thread Alan Gauld

On 13/08/13 23:38, Jake Wohldmann wrote:

Hello I am a beginner to using any type of script.  How long does it
take to become fluent at a script?


It depends on what you mean by Fluent.

I've spent 40+ years programming and am still learning.
OTOH I can usually learn enough about a new language to
start using it in a day.

Its like learning a musical instrument. You can bang
out a few chords and play a recognizable melody pretty
quickly. To be a maestro takes a lifetime.

Learn the basics then pick a project and go for it.
The more hands on you can get the better.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading a video

2013-08-15 Thread Alan Gauld

On 15/08/13 14:54, Zoya Tavakkoli wrote:


How can read a video frame by frame in python?


I'm not aware of anything that does it out of the
box in the standard library(*) so you will likely need
to use Google (or another equivalent) to find a
third party module.

But you will need to be much more specific.
There are a lot of video formats out there.
Which ones do you want to process?

(*)
But I'm always being surprised by what is in there!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python

2013-08-15 Thread Dave Angel
Jake Wohldmann wrote:

> Hello I am a beginner to using any type of script.  How long does it take
> to become fluent at a script?  I will only be able to practice python on
> weekends since school is starting.  I was also wondering if I could use
> python on my android phone.
>
>
> Hello I am a beginner to using any type of script.  How long 
> does it take to become fluent at a script?  I will only be able to practice 
> python on weekends since school is starting.  I was also wondering if I could 
> use python on my android phone. 
>

Please leave off the html part of your messages.  Tell your email
program to post text messages, not html.

We cannot tell how long a particular person might take to really learn
Python, when he has no previous experience in programming. It could be
weeks of full time work, or it could be years.

When I first studied a programming language it was at least 6 months,
and probably 8 before I first got access to a computer.  And that
language wasn't available, so I had to learn a second.  Neither of those
was as easy as Python, which didn't come till decades later.

Python was approximately the 35th language I've used at various jobs.

There are apparently ways to get Python on Android, but I have no
experience with it.


https://code.google.com/p/python-for-android/
http://www.amazon.com/MI1982-QPython-Python-on-Android/dp/B00AP36S4Y
http://qpython.com/
http://python-for-android.readthedocs.org/en/latest/android/
http://www.linuxjournal.com/article/10940
https://code.google.com/p/android-scripting/


-- 
DaveA


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python

2013-08-15 Thread Steven D'Aprano

On 14/08/13 08:38, Jake Wohldmann wrote:

Hello I am a beginner to using any type of script.  How long does it take
to become fluent at a script?


How long is a piece of string?

The answer could be anything from "a couple of hours" to "forever". It depends 
on:

- what scripting language are you using? (presumably Python)

- how smart and focused are you?

- how much effort and work are you willing and able to put it?

- can you practice regularly, before you forget your last practice session?

- do you have a natural inclination to programming?

- have you ever programmed before?

- what other programming languages do you know?

- what level of knowledge do you consider "fluent"?

If you're an intelligent, expert programmer with lots of experience in other languages, you could 
learn the basics of Python in a few minutes, and become fluent in hours. (Fluent, however, is not 
"expert".) If you can barely spell "PC" and spend all your time messing about 
on Youtube and Facebook, you'll never become fluent.

Given that we don't know the answer to any of those questions except the first, 
the only honest answer is, it will take as long as it takes. But as an 
extremely rough rule of thumb, for the average person who has never programmed 
before but has an inclination towards programming, it probably takes about 
1-200 hours of focused practice in a programming language to:

- learn the syntax and functionality of the base language and built-in types;

- become comfortable reading average code;

- learn the more common standard library functions;

- become comfortable searching the standard library for existing solutions 
instead of re-inventing the wheel;

- become able to write your own code following the standards and idioms common 
in the language;


which is what I consider moderately fluent.




I will only be able to practice python on
weekends since school is starting.  I was also wondering if I could use
python on my android phone.


Yes, but not trivially. First you have to be able to install software on your phone. Have 
you tried googling for "python android phone"?

https://duckduckgo.com/html/?q=python+android+phone



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python

2013-08-15 Thread Francois Dion
On Aug 15, 2013 8:04 PM, "Jake Wohldmann"  wrote:
>
>  I was also wondering if I could use python on my android phone.
>

Http://qpython.com

And then, there is the browser based approach. For example, see
http://raspberry-python.blogspot.com
That's using Brython and the interactive mode. Works on iPhone, iPad,
android (tested it on my nexus 7 HD)

Francois
--
www.pyptug.com   -  raspberry-python.blogspot.com  -  @f_dion
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading a video

2013-08-15 Thread Steven D'Aprano

On 15/08/13 23:54, Zoya Tavakkoli wrote:

Hi
How can read a video frame by frame in python?


Of course! Videos are just binary files, and Python can read binary files. The 
hard part is writing code that understands the internal structure of a video. 
There are many video formats (ogv, mp4, mov, avi, flv, mpg, asf, wmv, ram, to 
name just a few), and the internal structure of them will be different and not 
always documented anywhere, which may mean you have to reverse-engineer the 
format.

Doing this in pure Python code will likely be slow, unless you use an 
optimizing compiler like PyPy.

Your best best is to look for a library that already understands video formats. 
If there is no pre-existing Python library, there may be a C library with a 
Python interface. Of you can create your own Python interface, maybe using 
ctypes to talk to the library.

But honestly, it's probably a huge amount of work for something that will 
likely be rather slow, unless you use PyPy, in which case it will just be a 
huge amount of work. It will be less work if you only care about one video 
format.

What are you hoping to do with the frames once you get them? You may be better 
off using an external application like mplayer or ffmpeg to extract the frames 
to (say) png files, and then manipulate the images from Python, perhaps using 
PIL or similar.


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple Python SNMP ping?

2013-08-15 Thread Chris Down
Hi Leam,

On 2013-08-14 15:21, leam hall wrote:
> Is there a way to do a simple check in Python to see if a remote host is
> listening on SNMP port 161/UDP?

"Simple" in this case could either mean technically simple (in which case, use
a socket with SOCK_DGRAM and wait for data) or implementationally simple (in
which case, use an SNMP library). I'd only recommend doing the latter.

Since UDP is stateless, you'll need to make sure that your destination replies
with something, which means you probably need to send a real SNMP request.
Since that's the case, you should really just use a real SNMP library (although
I fear that your meaning of "simple" was "not using an SNMP library", which is
really not simple at all.

net-snmp[0] can do this fairly trivially, anyway. The following works for me:

>>> import netsnmp
>>> var = netsnmp.Varbind('sysDescr.0')
>>> netsnmp.snmpget(
... var,
... Version=2,
... DestHost="localhost",
... Community="pub",
... )
('OpenBSD',)

Best,

Chris

0: http://www.net-snmp.org/wiki/index.php/Python_Bindings


pgpfsJNUJXjPl.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor