Re: Reply to whom?

2016-02-05 Thread Mark Lawrence

On 04/02/2016 03:23, Bernardo Sulzbach wrote:

I see. I've bad experiences with Thunderbird in the past, but I will
try a desktop client again.



I've been using Thunderbird on Windows for years and never had a 
problem.  I read all Python mailing list, blogs, or whatever via gmane, 
it's a piece of cake.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Question about official API

2016-02-05 Thread Frank Millman

Hi all

What is the rule for knowing if something is part of the official API?

I have a queue.Queue(), I want to call q.join(), but I do not want it to 
block.


Looking at dir(q), I find an attribute 'unfinished_tasks'. It is an integer, 
and it looks like the counter referred to in the documentation for 
'task_done()'. I tried it out, and it does exactly what I want.


However, it is not mentioned in the documentation.

How do I know if it is safe to rely on this?

Thanks

Frank Millman


--
https://mail.python.org/mailman/listinfo/python-list


RE: Question about official API

2016-02-05 Thread Lutz Horn
Hi,

> What is the rule for knowing if something is part of the official API?

Look into https://docs.python.org/3/library/

Lutz
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about official API

2016-02-05 Thread Ben Finney
"Frank Millman"  writes:

> What is the rule for knowing if something is part of the official API?

Part of what official API?

Different libraries will have different rules about what is the official
API. Some may not have official rules.

For Python standard library modules, the official API is in the user
documentation for each module.

> However, it is not mentioned in the [standard library] documentation.

Then it's not part of the official API (or the documentation has a bug
which needs to be reported).

-- 
 \   “The long-term solution to mountains of waste is not more |
  `\  landfill sites but fewer shopping centres.” —Clive Hamilton, |
_o__)_Affluenza_, 2005 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about official API

2016-02-05 Thread Frank Millman
"Lutz Horn"  wrote in message 
news:blu178-w1837247af25e5755af69eb9e...@phx.gbl...



Hi,

> What is the rule for knowing if something is part of the official API?

Look into https://docs.python.org/3/library/



Thanks for the link, Lutz. Unfortunately I may have asked the wrong 
question.


In my specific case, how do I know if it is safe to use the attribute 
'unfinished_tasks' in the class queue.Queue?


It could be that it is intended for use, but has been omitted from the 
documentation in error.


Based on Ben's response I will raise an issue. At least that will settle the 
question one way or the other.


Frank





--
https://mail.python.org/mailman/listinfo/python-list


Re: Question about official API

2016-02-05 Thread Frank Millman

"Frank Millman"  wrote in message news:n91ndn$sc1$1...@ger.gmane.org...


Thanks for the link, Lutz. Unfortunately I may have asked the wrong 
question.


In my specific case, how do I know if it is safe to use the attribute 
'unfinished_tasks' in the class queue.Queue?


It could be that it is intended for use, but has been omitted from the 
documentation in error.


Based on Ben's response I will raise an issue. At least that will settle 
the question one way or the other.




http://bugs.python.org/issue26294



--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError> couldn't connect to display ":0

2016-02-05 Thread Dave Farrance
gemjack...@gmail.com wrote:

>This fixed my problem with thkinter.   sudo cp ~/.Xauthority ~root/

Which means that you were creating a GUI window with Python as root,
which is to be avoided if you can. If you can't avoid it and you're
running it with sudo in a bash console, rather than a root console, then
I'd suggest adding the line...

XAUTHORITY=$HOME/.Xauthority

...to the root's .bashrc which avoids putting a specific user's
xauthority file in the root directory.
-- 
https://mail.python.org/mailman/listinfo/python-list


sharepoint python

2016-02-05 Thread reach . ram2020
Hi Folks, 

Is there a python package available to check-in files from Unix to sharepoint?
I hope current sharepoint package is used to read from sharepoint server. 

Thanks,
Ramesh
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

On 05.02.2016 02:26, srinivas devaki wrote:

as I come to think of it again, it is not subheap, it actually heap cut at
some level hope you get the idea from the usage of _siftup. so even though
the `pos` children are valid the _siftup brings down the new element (i.e
the element which is at first at `pos`) upto its leaf level and then again
it is brought up by using _siftdown. why do the redundant work when it can
simply breakout?


The heapq module itself has a very extensive documentation inside. This 
is what it says for _siftup. I think this is sort of an optimization 
that works pretty well (cf. the numbers) for popping off the FIRST item:


"""

# The child indices of heap index pos are already heaps, and we want to 
make # a heap at index pos too. We do this by bubbling the smaller child 
of # pos up (and so on with that child's children, etc) until hitting a 
leaf, # then using _siftdown to move the oddball originally at index pos 
into place. # # We *could* break out of the loop as soon as we find a 
pos where newitem <= # both its children, but turns out that's not a 
good idea, and despite that # many books write the algorithm that way. 
During a heap pop, the last array # element is sifted in, and that tends 
to be large, so that comparing it # against values starting from the 
root usually doesn't pay (= usually doesn't # get us out of the loop 
early). See Knuth, Volume 3, where this is # explained and quantified in 
an exercise. # # Cutting the # of comparisons is important, since these 
routines have no # way to extract "the priority" from an array element, 
so that intelligence # is likely to be hiding in custom comparison 
methods, or in array elements # storing (priority, record) tuples. 
Comparisons are thus potentially # expensive. # # On random arrays of 
length 1000, making this change cut the number of # comparisons made by 
heapify() a little, and those made by exhaustive # heappop() a lot, in 
accord with theory. Here are typical results from 3 # runs (3 just to 
demonstrate how small the variance is): # # Compares needed by heapify 
Compares needed by 1000 heappops # -- 
 # 1837 cut to 1663 14996 cut to 8680 # 
1855 cut to 1659 14966 cut to 8678 # 1847 cut to 1660 15024 cut to 8703 
# # Building the heap by using heappush() 1000 times instead required # 
2198, 2148, and 2219 compares: heapify() is more efficient, when # you 
can use it. # # The total compares needed by list.sort() on the same 
lists were 8627, # 8627, and 8632 (this should be compared to the sum of 
heapify() and # heappop() compares): list.sort() is (unsurprisingly!) 
more efficient # for sorting.


"""

What do you think about our use-case?


_siftup and _siftdown are functions from python standard heapq module.

PS: I do competitive programming, I use these modules every couple of days
when compared to other modules. so didn't give much thought when posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)

Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 12:42 PM, Sven R. Kunze wrote:


PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)



I wonder why you *can* use this amount of already done stuff in 
competitive programming. When I was into that you could use what the 
standard library of the language gave you and nothing else.

--
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

On 05.02.2016 15:48, Bernardo Sulzbach wrote:

On 02/05/2016 12:42 PM, Sven R. Kunze wrote:


PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)



I wonder why you *can* use this amount of already done stuff in 
competitive programming. When I was into that you could use what the 
standard library of the language gave you and nothing else.


AFAICT, heapq is part of the standard lib. :)

Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 12:55 PM, Sven R. Kunze wrote:

On 05.02.2016 15:48, Bernardo Sulzbach wrote:

On 02/05/2016 12:42 PM, Sven R. Kunze wrote:


PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)



I wonder why you *can* use this amount of already done stuff in
competitive programming. When I was into that you could use what the
standard library of the language gave you and nothing else.


AFAICT, heapq is part of the standard lib. :)



Yes. I thought he was talking about XHEAP. However, rereading makes it 
look like he meant heapq indeed.

--
https://mail.python.org/mailman/listinfo/python-list


snmpset

2016-02-05 Thread Matt
How do I do the equivalent of this in Python?

snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test

and

snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123

and

snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1

and

snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread srinivas devaki
On Fri, Feb 5, 2016 at 8:12 PM, Sven R. Kunze  wrote:
> On 05.02.2016 02:26, srinivas devaki wrote:
> What do you think about our use-case?
>
Oh, the logic is sound, every element that we have inserted has to be popped,
We are spending some *extra* time in rearranging the elements only to be
sure that we won't be spending more than this *extra* time when doing other
operations, and our use-case isn't much different either, If by rearranging the
elements in the heap(*subheap*) gets optimal for other operations like
popping the
root element(heap[0]) then obviously it is optimal for popping other elements
(children of heap[0]).


PS: @sven But don't yet merge the pull request, I could be wrong.
as the heapq module already says that the variance is very small,
let me write some tests(on more than 10**3 elements) and then get back here.
-- 
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Zachary Ware
On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:
> How do I do the equivalent of this in Python?
>
> snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
>
> and
>
> snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
>
> and
>
> snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
>
> and
>
> snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2

I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
is far from a shining example of a Pythonic API and I don't envy you
if you should need to subclass something to change its behavior, but
it is effective.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

Hi srinivas,

I wrote this simple benchmark to measure comparisons:

import random

from xheapimport RemovalHeap


class X(object):
c =0 def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c +=1 return self.x < other.x

n =10 for jjin range(5):
items = [X(i)for iin range(n)]
random.shuffle(items)
heap = RemovalHeap(items)

random.shuffle(items)
for i  in items:
heap.remove(i)

print(X.c)
X.c =0


old version:
430457
430810
430657
429971
430583

your pull request version:
426414
426045
425437
425528
425522


Can we do better here?

Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

again for the list:
###


import random

from xheap import RemovalHeap


class X(object):
c = 0
def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c += 1
return self.x < other.x

n = 10

for jj in range(5):
items = [X(i) for i in range(n)]
random.shuffle(items)
heap = RemovalHeap(items)

random.shuffle(items)
for i in items:
heap.remove(i)

print(X.c)
X.c = 0


(note to myself: never copy PyCharm formatting strings to this list).

On 05.02.2016 17:27, Sven R. Kunze wrote:

Hi srinivas,

I wrote this simple benchmark to measure comparisons:

import random

from xheapimport RemovalHeap


class X(object):
c =0 def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c +=1 return self.x < other.x

n =10 for jjin range(5):
items = [X(i)for iin range(n)]
random.shuffle(items)
heap = RemovalHeap(items)

random.shuffle(items)
for i  in items:
heap.remove(i)

print(X.c)
X.c =0


old version:
430457
430810
430657
429971
430583

your pull request version:
426414
426045
425437
425528
425522


Can we do better here?

Best,
Sven


--
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware  wrote:

> On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:
> > How do I do the equivalent of this in Python?
> >
> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
> >
> > and
> >
> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
> >
> > and
> >
> > snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
> >
> > and
> >
> > snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2
>
> I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
> is far from a shining example of a Pythonic API and I don't envy you
> if you should need to subclass something to change its behavior, but
> it is effective.
>
> --
> Zach
> --
> https://mail.python.org/mailman/listinfo/python-list
>

That page 404s for me

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Zachary Ware
On Fri, Feb 5, 2016 at 11:12 AM, Joel Goldstick
 wrote:
> On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware > wrote:
>> I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
>
> That page 404s for me

Hmm, it works for me (just tried again).  Even Gmail's automatic
linkification didn't kill it.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Grant Edwards
On 2016-02-05, Joel Goldstick  wrote:

>> I have had success with pysnmp (http://pysnmp.sourceforge.net/).
>
> That page 404s for me

Looks like sourceforge is suffering an outage of some kind.

-- 
Grant Edwards   grant.b.edwardsYow! The FALAFEL SANDWICH
  at   lands on my HEAD and I
  gmail.combecome a VEGETARIAN ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 03:18 PM, Grant Edwards wrote:

On 2016-02-05, Joel Goldstick  wrote:


I have had success with pysnmp (http://pysnmp.sourceforge.net/).


That page 404s for me


Looks like sourceforge is suffering an outage of some kind.



Agree, it does not work for me right now.
--
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 12:12 PM, Joel Goldstick 
wrote:

>
>
> On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware <
> zachary.ware+pyl...@gmail.com> wrote:
>
>> On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:
>> > How do I do the equivalent of this in Python?
>> >
>> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
>> >
>> > and
>> >
>> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
>> >
>> > and
>> >
>> > snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
>> >
>> > and
>> >
>> > snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2
>>
>> I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
>> is far from a shining example of a Pythonic API and I don't envy you
>> if you should need to subclass something to change its behavior, but
>> it is effective.
>>
>> --
>> Zach
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> That page 404s for me.
>

Pardon me, looks like sourceforge is down

>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Johannes Findeisen
On Fri, 5 Feb 2016 12:12:58 -0500
Joel Goldstick wrote:

> On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware  > wrote:  
> 
> > On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:  
> > > How do I do the equivalent of this in Python?
> > >
> > > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
> > >
> > > and
> > >
> > > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
> > >
> > > and
> > >
> > > snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
> > >
> > > and
> > >
> > > snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2  
> >
> > I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
> > is far from a shining example of a Pythonic API and I don't envy you
> > if you should need to subclass something to change its behavior, but
> > it is effective.
> >
> > --
> > Zach
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >  
> 
> That page 404s for me

SourceForge seems to have problems at all... The Homepage is down too.

Johannes

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Zachary Ware
On Fri, Feb 5, 2016 at 11:14 AM, Joel Goldstick
 wrote:
> On Fri, Feb 5, 2016 at 12:12 PM, Joel Goldstick 
> wrote:
>> That page 404s for me.
>>
>
> Pardon me, looks like sourceforge is down

Ah, I guess caching fooled me when I rechecked.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sharepoint python

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 9:35 AM,  wrote:

> Hi Folks,
>
> Is there a python package available to check-in files from Unix to
> sharepoint?
> I hope current sharepoint package is used to read from sharepoint server.
>
> Thanks,
> Ramesh
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Does this help?  https://pypi.python.org/pypi/sharepoint/0.3.2

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sharepoint python

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 12:31 PM, Joel Goldstick 
wrote:

>
>
> On Fri, Feb 5, 2016 at 9:35 AM,  wrote:
>
>> Hi Folks,
>>
>> Is there a python package available to check-in files from Unix to
>> sharepoint?
>> I hope current sharepoint package is used to read from sharepoint server.
>>
>> Thanks,
>> Ramesh
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> Does this help?  https://pypi.python.org/pypi/sharepoint/0.3.2
>

or this:

http://stackoverflow.com/questions/23696705/how-to-upload-a-file-to-sharepoint-site-using-python-script


>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread srinivas devaki
wow, that's great.
you read a comment in the code, and you test it, to only find that it
is indeed true,
sounds ok, but feels great. :)

Just experimenting a bit, I swaped the lines _siftdown and _siftup and something
strange happened the number of comparisions in both the versions remained same.
I'm attaching the files.

do you have any idea why this happened?

On Fri, Feb 5, 2016 at 9:57 PM, Sven R. Kunze  wrote:
>
> Can we do better here?
>
I don't know, I have to read TAOP knuth article.

-- 
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight
-- 
https://mail.python.org/mailman/listinfo/python-list


Daemon strategy

2016-02-05 Thread paul . hermeneutic
It appears that python-deamon would be exactly what I need. Alas,
appears not to run on Windows. If I am wrong about that, please tell
me.

To what tools should I turn?

I am not eager to produce a "service" on Windows unless it cannot be avoided.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread Ben Finney
paul.hermeneu...@gmail.com writes:

> It appears that python-deamon would be exactly what I need. Alas,
> appears not to run on Windows. If I am wrong about that, please tell
> me.

You're correct that ‘python-daemon’ uses Unix facilities to create a
well-behaved Unix daemon process.

Since MS Windows lacks those facilities, ‘python-daemon’ can't use them.

> To what tools should I turn?

If what you need – the support to create a Unix daemon process – is
available only on Unix by definition, it seems you'll need to deploy to
Unix.

> I am not eager to produce a "service" on Windows unless it cannot be
> avoided.

Agreed :-)

-- 
 \ “Wrinkles should merely indicate where smiles have been.” —Mark |
  `\Twain, _Following the Equator_ |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread Ray Cote
We’ve recently stopped building Windows services (Python or any other type)
and started using the NSSM service manager.
Takes a normal Windows application and runs it as a service.
The NSSM service manager provides great command-line support for
installing, configuring, and controlling Windows services.
Has greatly reduced our development time and test time since we no longer
need to test both app and service executables.



Downside is that it is a separate tool to install.
Upside is that it has features such as :
  - run-once at startup.
  - auto-restart failed services
  - setting service dependences (don’t start until another service is up
and running)
  - set processor dependencies

—Ray


On Fri, Feb 5, 2016 at 1:39 PM,  wrote:

> It appears that python-deamon would be exactly what I need. Alas,
> appears not to run on Windows. If I am wrong about that, please tell
> me.
>
> To what tools should I turn?
>
> I am not eager to produce a "service" on Windows unless it cannot be
> avoided.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Raymond Cote, President
voice: +1.603.924.6079 email: rgac...@appropriatesolutions.com skype:
ray.cote
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread Nathan Hilterbrand



On 02/05/2016 01:39 PM, paul.hermeneu...@gmail.com wrote:

It appears that python-deamon would be exactly what I need. Alas,
appears not to run on Windows. If I am wrong about that, please tell
me.

To what tools should I turn?

I am not eager to produce a "service" on Windows unless it cannot be avoided.


I am not 100% sure exactly what you want to do, but you might take a 
look at using 'pythonw.exe' instead of 'python.exe'


YMMV

Nathan
--
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread paul . hermeneutic
On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney  wrote:
> paul.hermeneu...@gmail.com writes:
>
>> It appears that python-deamon would be exactly what I need. Alas,
>> appears not to run on Windows. If I am wrong about that, please tell
>> me.
>
> You're correct that ‘python-daemon’ uses Unix facilities to create a
> well-behaved Unix daemon process.
>
> Since MS Windows lacks those facilities, ‘python-daemon’ can't use them.

As you might imagine, I am not always able to specify which OS is
deployed. That does not mean that I am not responsible for getting the
work done. Perhaps you will tell me that what I want is not a daemon.

BTW, I thought that pip would know that python-daemon would not run on
my machine, but it had no complaints installing it. That gave me
unmerited hope.

I want to create a program that will run a list of command lines. Some
of the tasks might take 42 milliseconds, but others might take 4.2
hours. I need to be able to:

- list the tasks currently being run
- kill a task that is currently being run
- list the tasks that are not yet run
- delete a task not yet run from the list
- add tasks to the list

The goal is to load the machine up to a specified percentage of
CPU/memory/io bandwidth. I want to keep the machine loaded up to 90%
of capacity. It is important to monitor more than just CPU utilization
because the machine may already be over-committed on memory while CPU
utilization is low. Adding more processes in such an environment just
makes the system go slower.

I realize that high-end schedulers like IBM/Tivoli, CA7, and BMC might
do things like that. Those are not usually within budget.

Is a daemon what I need? Any other suggestions?
-- 
https://mail.python.org/mailman/listinfo/python-list


realtime output and csv files

2016-02-05 Thread lucan

I'm new of python adn I'm using it only to complete some experiments.
I'm reading a series of data from various sensors and in the meantime 
I'm writing datas on a file. I would like to print output in realtime 
(or refresh it when I need) but the problem is that I'm writing on a 
file every x seconds (my timestep).
Anyway from the moment that datas are scientific value is it correct to 
write on a file using str(temp) and separating with ","?

I need a csv file to read it with some data analysis softwares.


...
now = datetime.datetime.now()
dayexperiment = str(now.day)+str(now.month)+str(now.year)

myfilename ="myData"+dayexperiment+".dat"

index = 0
count = 1

timestep = 10


with open(myfilename,'w') as f:
f.write('#Index Time Value')
while True:
reading = ...
...
temp=...

print 'Temp{0:0.3F}*C'.format(temp)

now = datetime.datetime.now()
file.write('\n'+str(index))

f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+', '+str(temp))

index +=1
time.sleep(timestep)





--
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 05:49 PM, lucan wrote:

Anyway from the moment that datas are scientific value is it correct to
write on a file using str(temp) and separating with ","?
I need a csv file to read it with some data analysis softwares.



What do you mean? What is "datas"? What do you mean by "correct"?

CSVs is essentially text separated by commas, so you likely do not need 
any library to write it "Just separating with ','" should work if you 
are formatting them correctly.

--
https://mail.python.org/mailman/listinfo/python-list


Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
I am running this python script on R-studio. I have Python 3.5 installed on my 
system.

count = 10
while (count > 0):
try :
# read line from file:
print(file.readline())
# parse
parse_json(file.readline())
count = count - 1
except socket.error as e
print('Connection fail', e)
print(traceback.format_exc())

# wait for user input to end
# input("\n Press Enter to exit...");
# close the SSLSocket, will also close the underlying socket
ssl_sock.close()
The error I am getting is here:

line 53 except socket.error as e ^ SyntaxError: invalid syntax

I tried changing socket.error to ConnectionRefusedError. and still got the same 
error.

Please tell me if the problem is with Rstudio, Python version or the syntax.

TIA
-Shaunak
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Nathan Hilterbrand
On Feb 5, 2016 15:01,  wrote:
>
> I am running this python script on R-studio. I have Python 3.5 installed
on my system.
>
> count = 10
> while (count > 0):
> try :
> # read line from file:
> print(file.readline())
> # parse
> parse_json(file.readline())
> count = count - 1
> except socket.error as e
> print('Connection fail', e)
> print(traceback.format_exc())
>
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
>
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
> I tried changing socket.error to ConnectionRefusedError. and still got
the same error.
>
> Please tell me if the problem is with Rstudio, Python version or the
syntax.
>
> TIA
> -Shaunak
> --
> https://mail.python.org/mailman/listinfo/python-list

Looks like you are missing a colon after 'as e'... as e:  might do
the trick

Nathan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Martin A. Brown

>except socket.error as e

>line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
>I tried changing socket.error to ConnectionRefusedError. and still 
>got the same error.

>Please tell me if the problem is with Rstudio, Python version or 
>the syntax.

Syntax.

Your code has, unfortunately, suffered a colonectomy.

When you transplant a colon, it is more likely to function properly 
again.  For example:

   except socket.error as e:

Good luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 1:08:11 PM UTC-7, Nathan Hilterbrand wrote:
> On Feb 5, 2016 15:01,  wrote:
> >
> > I am running this python script on R-studio. I have Python 3.5 installed
> on my system.
> >
> > count = 10
> > while (count > 0):
> > try :
> > # read line from file:
> > print(file.readline())
> > # parse
> > parse_json(file.readline())
> > count = count - 1
> > except socket.error as e
> > print('Connection fail', e)
> > print(traceback.format_exc())
> >
> > # wait for user input to end
> > # input("\n Press Enter to exit...");
> > # close the SSLSocket, will also close the underlying socket
> > ssl_sock.close()
> > The error I am getting is here:
> >
> > line 53 except socket.error as e ^ SyntaxError: invalid syntax
> >
> > I tried changing socket.error to ConnectionRefusedError. and still got
> the same error.
> >
> > Please tell me if the problem is with Rstudio, Python version or the
> syntax.
> >
> > TIA
> > -Shaunak
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> Looks like you are missing a colon after 'as e'... as e:  might do
> the trick
> 
> Nathan

Hi Nathan,

Tried colon and a comma as well. Both did not work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 1:11:19 PM UTC-7, shaunak...@gmail.com wrote:
> On Friday, February 5, 2016 at 1:08:11 PM UTC-7, Nathan Hilterbrand wrote:
> > On Feb 5, 2016 15:01,  wrote:
> > >
> > > I am running this python script on R-studio. I have Python 3.5 installed
> > on my system.
> > >
> > > count = 10
> > > while (count > 0):
> > > try :
> > > # read line from file:
> > > print(file.readline())
> > > # parse
> > > parse_json(file.readline())
> > > count = count - 1
> > > except socket.error as e
> > > print('Connection fail', e)
> > > print(traceback.format_exc())
> > >
> > > # wait for user input to end
> > > # input("\n Press Enter to exit...");
> > > # close the SSLSocket, will also close the underlying socket
> > > ssl_sock.close()
> > > The error I am getting is here:
> > >
> > > line 53 except socket.error as e ^ SyntaxError: invalid syntax
> > >
> > > I tried changing socket.error to ConnectionRefusedError. and still got
> > the same error.
> > >
> > > Please tell me if the problem is with Rstudio, Python version or the
> > syntax.
> > >
> > > TIA
> > > -Shaunak
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > 
> > Looks like you are missing a colon after 'as e'... as e:  might do
> > the trick
> > 
> > Nathan
> 
> Hi Nathan,
> 
> Tried colon and a comma as well. Both did not work.

Of course I am new to Python. I am wondering if it has to do anything with the 
indentation. Putting my most recent code here, again:

try :
# read line from file:
print(file.readline())
# parse
parse_json(file.readline())
count = count - 1
except socket.error as e:
print('Connection fail', e)
print(traceback.format_exc())
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 1:09:35 PM UTC-7, Martin A. Brown wrote:
> >except socket.error as e
> 
> >line 53 except socket.error as e ^ SyntaxError: invalid syntax
> >
> >I tried changing socket.error to ConnectionRefusedError. and still 
> >got the same error.
> 
> >Please tell me if the problem is with Rstudio, Python version or 
> >the syntax.
> 
> Syntax.
> 
> Your code has, unfortunately, suffered a colonectomy.
> 
> When you transplant a colon, it is more likely to function properly 
> again.  For example:
> 
>except socket.error as e:
> 
> Good luck,
> 
> -Martin
> 
> -- 
> Martin A. Brown
> http://linux-ip.net/

I was first running with a colon only. Later tried with a comma. But it didn't 
work. I got the same error.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Martin A. Brown

Hi there Shaunak,

I saw your few replies to my (and Nathan's) quick identification of 
syntax error.  More comments follow, here.

>I am running this python script on R-studio. I have Python 3.5 installed on my 
>system.
>
>count = 10
>while (count > 0):
>try :
># read line from file:
>print(file.readline())
># parse
>parse_json(file.readline())
>count = count - 1
>except socket.error as e
>print('Connection fail', e)
>print(traceback.format_exc())
>
># wait for user input to end
># input("\n Press Enter to exit...");
># close the SSLSocket, will also close the underlying socket
>ssl_sock.close()
>
>The error I am getting is here:
>
>line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
>I tried changing socket.error to ConnectionRefusedError. and still got the 
>same error.

We were assuming that line 53 in your file is the part you pasted 
above.  That clearly shows a syntax error (the missing colon).

If, after fixing that error, you are still seeing errors, then the 
probable explanations are:

  * you are not executing the same file you are editing

  * there is a separate syntax error elsewhere in the file (you sent
us only a fragment)

Additional points:

  * While the word 'file' is not reserved in Python 3.x, it is in 
Python 2.x, so, just be careful when working with older Python 
versions.  You could always change your variable name, but you 
do not need to.

  * When you catch the error in the above, you print the traceback 
information, but your loop will continue.  Is that what you 
desired?

I might suggest saving your work carefully and make sure that you 
are running the same code that you are working on.  Then, if you 
are still experiencing syntax errors, study the lines that the 
interpreter is complaining about.  And, of course, send the list an 
email.

Best of luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Chris Angelico
On Sat, Feb 6, 2016 at 6:58 AM,   wrote:
> I am running this python script on R-studio. I have Python 3.5 installed on 
> my system.
>

Let's just try a quick smoke test. Run this script:

import sys
print(sys.version)
input("Press Enter to exit...")

That'll tell you a few things about how your system is set up. Most
notably, if it doesn't say you're using Python 3.5, there's a problem.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Martin A. Brown

Hi there,

>Thanks for the detailed reply. I edited, saved and opened the file 
>again. Still I am getting exactly the same error.
>
>Putting bigger chunk of code and the error again:

[snipped; thanks for the larger chunk]

>Error:
>except socket.error as e:
> ^
>SyntaxError: invalid syntax

I ran your code.  I see this:

  $ python3 shaunak.bangale.py 
  Connecting...
  Connection succeeded
  Traceback (most recent call last):
File "shaunak.bangale.py", line 23, in 
  ssl_sock.write(bytes(initiation_command, 'UTF-8'))
  NameError: name 'initiation_command' is not defined

Strictly speaking, I don't think you are having a Python problem.

  * Are you absolutely certain you are (or your IDE is) executing 
the same code you are writing?

  * How would you be able to tell?  Close your IDE.  Run the code on 
the command-line.

  * How much time have you taken to work out what the interpreter is 
telling you?

Good luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:01 PM, Chris Angelico wrote:

On Sat, Feb 6, 2016 at 6:58 AM,   wrote:

I am running this python script on R-studio. I have Python 3.5 installed on my 
system.



Let's just try a quick smoke test. Run this script:

import sys
print(sys.version)
input("Press Enter to exit...")

That'll tell you a few things about how your system is set up. Most
notably, if it doesn't say you're using Python 3.5, there's a problem.

ChrisA



Is there? If he just got the minor version wrong it wouldn't be a 
problem. Unless RStudio requires 3.**5** for some reason.

--
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread lucan



What do you mean? What is "datas"? What do you mean by "correct"?


"datas" I mean the values for example temperature = 20.4 (so they are 
floating point)


Index time temp
1 10:24 20.4
2 10:25 20.6
...

I wonder if this is correct "my way" to write a csv file:

file.write('\n'+str(index)) 
f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+','+str(temp))


Or if there is a better way to do that.


CSVs is essentially text separated by commas, so you likely do not need
any library to write it "Just separating with ','" should work if you
are formatting them correctly.


ok.

--
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:09 PM, lucan wrote:



What do you mean? What is "datas"? What do you mean by "correct"?


"datas" I mean the values for example temperature = 20.4 (so they are
floating point)

Index time temp
1 10:24 20.4
2 10:25 20.6
...

I wonder if this is correct "my way" to write a csv file:

file.write('\n'+str(index))
f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+','+str(temp))

Or if there is a better way to do that.



If you got your newlines and headers (if the other program requires it) 
right, this should be all you need.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 2:09:11 PM UTC-7, Bernardo Sulzbach wrote:
> On 02/05/2016 07:01 PM, Chris Angelico wrote:
> > On Sat, Feb 6, 2016 at 6:58 AM,   wrote:
> >> I am running this python script on R-studio. I have Python 3.5 installed 
> >> on my system.
> >>
> >
> > Let's just try a quick smoke test. Run this script:
> >
> > import sys
> > print(sys.version)
> > input("Press Enter to exit...")
> >
> > That'll tell you a few things about how your system is set up. Most
> > notably, if it doesn't say you're using Python 3.5, there's a problem.
> >
> > ChrisA
> >
> 
> Is there? If he just got the minor version wrong it wouldn't be a 
> problem. Unless RStudio requires 3.**5** for some reason.

Hi Chris,
Output:

3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)]

Hi Martin,

I do have the initiation command defined. Just that I am not allowed to make 
the username, pwd public.

I am absolutely sure I am running the same code. Now opened the same file with 
Python 3.5 shell and I get following error:

   from _ssl import RAND_status, RAND_egd, RAND_add
ImportError: cannot import name 'RAND_egd'

I am new to coding and this code has been borrowed from an online source but I 
can see same code working on mac+Rstudio+python combo.

Salute your patience.

Sincerely,
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:26 PM, shaunak.bang...@gmail.com wrote:


from _ssl import RAND_status, RAND_egd, RAND_add
ImportError: cannot import name 'RAND_egd'



I believe I've already seen this issue myself. It has to do with 
LibreSSL not having RAND_egd for some reason I can't recall.


This seems to be the related ticket https://bugs.python.org/issue21356

On 02/05/2016 07:26 PM, shaunak.bang...@gmail.com wrote:
> I am new to coding and this code has been borrowed from an online
> source but I can see same code working on mac+Rstudio+python combo.

Are you sure that the Python you talk about is 3.5?
--
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 4:13 PM, Bernardo Sulzbach  wrote:

> On 02/05/2016 07:09 PM, lucan wrote:
>
>>
>> What do you mean? What is "datas"? What do you mean by "correct"?
>>>
>>
>> "datas" I mean the values for example temperature = 20.4 (so they are
>> floating point)
>>
>> Index time temp
>> 1 10:24 20.4
>> 2 10:25 20.6
>> ...
>>
>> I wonder if this is correct "my way" to write a csv file:
>>
>> file.write('\n'+str(index))
>> f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+','+str(temp))
>>
>
You might want to do this:

f.write("%d, %2d:%2d, %.1f" % (index, now.hour, now.minute, temp))

In my test:

>>> print("%d, %2d:%2d, %.1f" % (1,10,24,20.4))
1, 10:24, 20.4

This uses the original python formatting method.  There is a newer one as
well

>
>> Or if there is a better way to do that.
>>
>>
> If you got your newlines and headers (if the other program requires it)
> right, this should be all you need.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:43 PM, Joel Goldstick wrote:

print("%d, %2d:%2d, %.1f" % (1,10,24,20.4))

1, 10:24, 20.4


Let us be more careful there. Although CSV has no formal specification 
(according to the IETF), *those spaces are not good*.


It is **very unlikely** that they will cause issues, but 1,10:24,20.4 is 
*safer* and - to my eyes - better CSV.


I wouldn't be surprised if a parser treated a value as text only because 
it has spaces on it.


For OP, if you are going for this, I - personally - suggest sticking to 
"%d,%2d:%2d,%.1f".

--
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Chris Angelico
On Sat, Feb 6, 2016 at 8:08 AM, Bernardo Sulzbach
 wrote:
> On 02/05/2016 07:01 PM, Chris Angelico wrote:
>>
>> On Sat, Feb 6, 2016 at 6:58 AM,   wrote:
>>>
>>> I am running this python script on R-studio. I have Python 3.5 installed
>>> on my system.
>>>
>>
>> Let's just try a quick smoke test. Run this script:
>>
>> import sys
>> print(sys.version)
>> input("Press Enter to exit...")
>>
>> That'll tell you a few things about how your system is set up. Most
>> notably, if it doesn't say you're using Python 3.5, there's a problem.
>>
>> ChrisA
>>
>
> Is there? If he just got the minor version wrong it wouldn't be a problem.
> Unless RStudio requires 3.**5** for some reason.

Stuff might work, but if you think you're using 3.5 and you're
actually running under 3.4, there's a high probability that you have
two Python installations and it's picking the wrong one. That, in
turn, means problems with package installations and such, so it's a
reasonable smoke test to try. (It's unlikely there'll be two different
3.5s installed.) And, of course, if it shows up that it's running
under *2*.5, well, that would explain a lot :)

Anyway, it is indeed what's expected - smoke test passed.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 12:58:37 PM UTC-7, shaunak...@gmail.com wrote:
> I am running this python script on R-studio. I have Python 3.5 installed on 
> my system.
> 
> count = 10
> while (count > 0):
> try :
> # read line from file:
> print(file.readline())
> # parse
> parse_json(file.readline())
> count = count - 1
> except socket.error as e
> print('Connection fail', e)
> print(traceback.format_exc())
> 
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
> 
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
> 
> I tried changing socket.error to ConnectionRefusedError. and still got the 
> same error.
> 
> Please tell me if the problem is with Rstudio, Python version or the syntax.
> 
> TIA
> -Shaunak

It is 3.5. I am looking at the link.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 4:51 PM, Bernardo Sulzbach  wrote:

> On 02/05/2016 07:43 PM, Joel Goldstick wrote:
>
>> print("%d, %2d:%2d, %.1f" % (1,10,24,20.4))
>
 1, 10:24, 20.4
>>
>
> Let us be more careful there. Although CSV has no formal specification
> (according to the IETF), *those spaces are not good*.
>
> It is **very unlikely** that they will cause issues, but 1,10:24,20.4 is
> *safer* and - to my eyes - better CSV.
>
> I wouldn't be surprised if a parser treated a value as text only because
> it has spaces on it.
>
> For OP, if you are going for this, I - personally - suggest sticking to
> "%d,%2d:%2d,%.1f".


Good point!

>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 12:58:37 PM UTC-7, shaunak...@gmail.com wrote:
> I am running this python script on R-studio. I have Python 3.5 installed on 
> my system.
> 
> count = 10
> while (count > 0):
> try :
> # read line from file:
> print(file.readline())
> # parse
> parse_json(file.readline())
> count = count - 1
> except socket.error as e
> print('Connection fail', e)
> print(traceback.format_exc())
> 
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
> 
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
> 
> I tried changing socket.error to ConnectionRefusedError. and still got the 
> same error.
> 
> Please tell me if the problem is with Rstudio, Python version or the syntax.
> 
> TIA
> -Shaunak


Chris,

That sounds legitimate.
But I never installed second 3.X version and deleted previous 2.X version and 
using only 3.5 now. What will be the next test according to you?

-Shaun
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread Ben Finney
paul.hermeneu...@gmail.com writes:

> On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney  
> wrote:
> > Since MS Windows lacks those facilities, ‘python-daemon’ can't use
> > them.
>
> As you might imagine, I am not always able to specify which OS is
> deployed. That does not mean that I am not responsible for getting the
> work done. Perhaps you will tell me that what I want is not a daemon.

I'm telling you none of those. What I'm telling you is MS Windows does
not support what is needed to make a Unix daemon.

You may need to re-visit the requirements and negotiate something
different — a different deployment platform, or something which MS
Windows can do which is less than a proper Unix daemon.

> BTW, I thought that pip would know that python-daemon would not run on
> my machine, but it had no complaints installing it. That gave me
> unmerited hope.

Sorry to learn that. The PyPI metadata for ‘python-daemon’
https://pypi.python.org/pypi/python-daemon/> explicitly declares
the supported OS limited to “Operating System :: POSIX”, which MS
Windows is not compatible with.

If ‘pip’ does not honour that field and inform you of the
incompatibility, you may want to report a bug to the ‘pip’ developers.

-- 
 \   “My business is to teach my aspirations to conform themselves |
  `\  to fact, not to try and make facts harmonise with my |
_o__)   aspirations.“ —Thomas Henry Huxley, 1860-09-23 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to resize an animated gif to fit the window

2016-02-05 Thread Emile van Sebille
Googling that finds 
https://cloud.google.com/appengine/docs/python/images/ which may be of 
some help.


Emile


On 1/29/2016 5:50 PM, kwe...@gmail.com wrote:

Hi, I am able to display animated gif using pyglet using below code, but I 
would like the image to stretch and fit the window as i resize the window.
Any one can help me?

import pyglet
# pick an animated gif file you have in the working directory

CODE: SELECT ALL
def animate(str):
 ag_file = str
 animation = pyglet.resource.animation(ag_file)
 sprite = pyglet.sprite.Sprite(animation)
 # create a window and set it to the image size
 win = pyglet.window.Window(width=sprite.width, height=sprite.height)

 @win.event
 def on_draw():
 win.clear()
 sprite.draw()

 pyglet.app.run()

animate("***.gif")


CODE: SELECT ALL
win = pyglet.window.Window(width=sprite.width, height=sprite.height)

Above line will resize the window to fit the animated gif but i want it the 
other way, that is the gif to fit the windows size..




--
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Chris Angelico
On Sat, Feb 6, 2016 at 9:35 AM,   wrote:
> On Friday, February 5, 2016 at 12:58:37 PM UTC-7, shaunak...@gmail.com wrote:
>> I am running this python script on R-studio. I have Python 3.5 installed on 
>> my system.
>>
>> count = 10
>> while (count > 0):
>> try :
>> # read line from file:
>> print(file.readline())
>> # parse
>> parse_json(file.readline())
>> count = count - 1
>> except socket.error as e
>> print('Connection fail', e)
>> print(traceback.format_exc())
>>
>> # wait for user input to end
>> # input("\n Press Enter to exit...");
>> # close the SSLSocket, will also close the underlying socket
>> ssl_sock.close()
>> The error I am getting is here:
>>
>> line 53 except socket.error as e ^ SyntaxError: invalid syntax
>>
>> I tried changing socket.error to ConnectionRefusedError. and still got the 
>> same error.
>>
>> Please tell me if the problem is with Rstudio, Python version or the syntax.
>>
>> TIA
>> -Shaunak
>
>
> Chris,
>
> That sounds legitimate.
> But I never installed second 3.X version and deleted previous 2.X version and 
> using only 3.5 now. What will be the next test according to you?

(Please quote the person you're replying to, rather than simply
quoting your own original post - it helps to provide context. Thanks!)

The next thing to try would be to add the colon at the end of the
"except" clause, as has already been suggested, and then to post the
latest code (preferably all of it - if it looks like too much, it's
worth shortening the code, rather than posting a snippet) and the full
traceback.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Tim Chase
On 2016-02-05 17:57, Bernardo Sulzbach wrote:
> CSVs is essentially text separated by commas, so you likely do not
> need any library to write it "Just separating with ','" should work
> if you are formatting them correctly.

> https://mail.python.org/mailman/listinfo/python-list
And even if you have things to escape or format correctly, the stdlib
has a "csv" module that makes this trivially easy:

  data = [
(1, 3.14, "hello"),
(2, 1.41, "goodbye"),
]
  from csv import writer
  with open("out.csv", "wb") as f:
w = writer(f)
w.writerows(data)
# for row in data:
# w.writerow(data)

-tkc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach
On Sat, Feb 6, 2016 at 2:27 AM, Tim Chase  wrote:
> On 2016-02-05 17:57, Bernardo Sulzbach wrote:
>> CSVs is essentially text separated by commas, so you likely do not
>> need any library to write it "Just separating with ','" should work
>> if you are formatting them correctly.
>
>> https://mail.python.org/mailman/listinfo/python-list
> And even if you have things to escape or format correctly, the stdlib
> has a "csv" module that makes this trivially easy:
>

I supposed it had one. Obviously, I've never used it myself, otherwise
I would be sure about its existence. Nice to know about it, although I
assume that for many data transfers it will not be painless if you
need several escapes, when CSV starts to become complicated it starts
to fail because of quirky and naive parsers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread Ian Kelly
On Fri, Feb 5, 2016 at 4:10 PM, Ben Finney  wrote:
> Sorry to learn that. The PyPI metadata for ‘python-daemon’
> https://pypi.python.org/pypi/python-daemon/> explicitly declares
> the supported OS limited to “Operating System :: POSIX”, which MS
> Windows is not compatible with.

Depends on the version: https://en.wikipedia.org/wiki/Windows_Services_for_UNIX

Unfortunately that's no longer available for modern Windows. But it's
not the only option either:
https://en.wikipedia.org/wiki/POSIX#POSIX_for_Windows

> If ‘pip’ does not honour that field and inform you of the
> incompatibility, you may want to report a bug to the ‘pip’ developers.

Linux and FreeBSD are also not POSIX-certified, even though they
mostly comply. Should pip warn about those also?
-- 
https://mail.python.org/mailman/listinfo/python-list