Re: Concatenation of multiple video files in single file

2020-05-09 Thread Wildman via Python-list
On Sat, 09 May 2020 22:06:01 +0530, Akshay Ghodake wrote:

> Hello,
> 
> I want a help to concatenation of multiple video files into a single file
> in python.
> 
> Any help will be greatly appreciated.
> 
> Best regards,
> Akshay Ghodake

This might help...

https://kkroening.github.io/ffmpeg-python/

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please solve this problem

2020-03-09 Thread Wildman via Python-list
On Mon, 09 Mar 2020 11:47:24 +0530, sachin thakur wrote:

What is the problem?  If you attached a screenshot to your post
it was dropped.  This is a text only group.  Explain the problem
or put the screenshot on a cloud site such as Dropbox and post
the link.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: No module named Adafruit_SSD1306

2019-12-04 Thread Wildman via Python-list
On Wed, 04 Dec 2019 20:25:33 +, RobH wrote:

> I am trying to do this project on a pi zero:
> 
> http://frederickvandenbosch.be/?p=1365
> 
> I copied the code to the pi zero Download folder and when I run it I get 
> the above error at line 4
> Import Adafruit_SSD1306
> 
> I am using python version 2.7.16, if that makes any difference
> I have the same module as the authors' link goes to :
> 
> Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic
> 
> Have I missed something.

The error indicates that Adafruit_SSD1306 in not installed.

https://github.com/adafruit/Adafruit_Python_SSD1306

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launching a Script on the Linux Platform

2019-11-18 Thread Wildman via Python-list
On Mon, 18 Nov 2019 22:15:31 +0100, Peter J. Holzer wrote:

> On 2019-11-18 15:01:57 -0600, Wildman via Python-list wrote:
>> On Tue, 19 Nov 2019 05:09:07 +1100, Chris Angelico wrote:
>> > On Tue, Nov 19, 2019 at 5:06 AM Wildman via Python-list
>> >  wrote:
>> >> On Sun, 17 Nov 2019 18:27:45 +, Barry Scott wrote:
>> >> > Because you are installing from a deb you know the exact path to the 
>> >> > python you
>> >> > need to use. There is no need to use the /usr/bin/env to search the 
>> >> > path and
>> >> > potential break your code, because a version of python that you do not 
>> >> > expect is on
>> >> > the path.
>> >>
>> >> I don't understand.  The deb does not install python so I
>> >> fail to see how I would know the exact path.
>> >>
>> >> As to env breaking my code, never heard of such a thing.
>> >>
>> > 
>> > The deb should depend on an appropriate Python package. Then you can
>> > assume and expect that this version of Python is installed.
>> 
>> Yes, of course, python(3) is listed as a "depends" in the deb
>> control file.  That does insure that python is installed but
>> in no way does that tell me the path of the python executable.
> 
> The debian packaging guidelines tell you where the execuable has to be.
> If you install the python package you can be very sure that the
> executable will be in /usr/bin. And this is the executable you want to
> use. You don't want to use some other random program called "python"
> (which may or may not be an interpreter for some version of the Python
> language) which just happens to be in the user's path.
> 
> hp

Yes, /usr/bin is the likely place to find the python executable
but a guideline is not a guarantee.  I have always been taught
it is never a good idea to use a hard path unless it is something
installed with your program or something created by your program.
That approach has not failed me.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launching a Script on the Linux Platform

2019-11-18 Thread Wildman via Python-list
On Tue, 19 Nov 2019 05:09:07 +1100, Chris Angelico wrote:

> On Tue, Nov 19, 2019 at 5:06 AM Wildman via Python-list
>  wrote:
>>
>> On Sun, 17 Nov 2019 18:27:45 +, Barry Scott wrote:
>>
>> >> On 12 Nov 2019, at 20:24, Wildman via Python-list 
>> >>  wrote:
>> >>
>> >> Yes, I prefer to envoke env in the shebang line instead of
>> >> depending on the path.  Paths can change especially in a
>> >> multi-user system but env will always know where to find
>> >> the executable.
>> >
>> > The path to python will not change surely?
>>
>> In Linux, being a multi-user OS, the path is not global or
>> system wide.  The path can be different for different users.
>> This is done by adding an EXPORT command to ~/.bashrc.
>>
>> > Because you are installing from a deb you know the exact path to the 
>> > python you
>> > need to use. There is no need to use the /usr/bin/env to search the path 
>> > and
>> > potential break your code, because a version of python that you do not 
>> > expect is on
>> > the path.
>> >
>> > Barry
>>
>> I don't understand.  The deb does not install python so I
>> fail to see how I would know the exact path.
>>
>> As to env breaking my code, never heard of such a thing.
>>
> 
> The deb should depend on an appropriate Python package. Then you can
> assume and expect that this version of Python is installed.
> 
> ChrisA

Yes, of course, python(3) is listed as a "depends" in the deb
control file.  That does insure that python is installed but
in no way does that tell me the path of the python executable.

-- 
 GNU/Linux user #557453
"Be at war with your vices, at peace with your neighbors
and let every new year find you a better man."
  -Benjamin Franklin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launching a Script on the Linux Platform

2019-11-18 Thread Wildman via Python-list
On Sun, 17 Nov 2019 18:27:45 +, Barry Scott wrote:

>> On 12 Nov 2019, at 20:24, Wildman via Python-list  
>> wrote:
>> 
>> Yes, I prefer to envoke env in the shebang line instead of
>> depending on the path.  Paths can change especially in a
>> multi-user system but env will always know where to find
>> the executable.
> 
> The path to python will not change surely?

In Linux, being a multi-user OS, the path is not global or
system wide.  The path can be different for different users.
This is done by adding an EXPORT command to ~/.bashrc.

> Because you are installing from a deb you know the exact path to the python 
> you
> need to use. There is no need to use the /usr/bin/env to search the path and
> potential break your code, because a version of python that you do not expect 
> is on
> the path.
> 
> Barry

I don't understand.  The deb does not install python so I
fail to see how I would know the exact path.

As to env breaking my code, never heard of such a thing.

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launching a Script on the Linux Platform

2019-11-12 Thread Wildman via Python-list
On Tue, 12 Nov 2019 18:39:38 +, Rhodri James wrote:

> On 12/11/2019 18:25, Rob Gaddi wrote:
>> On 11/12/19 10:06 AM, Wildman wrote:
>>> What is the best approach for launching a Python GUI program
>>> on a Linux platform.  The program will be distributed in .deb
>>> format.  So the .deb will contain a menu file as well as a
>>> .desktop file.  The post install script will update the system
>>> menu.
>>>
>>> My question is how should the program be executed?  Here are
>>> two choices for the "command=" entry in the menu file...
>>>
>>> command="/path/to/program.py"
>>>
>>> In this case the hash-bang would have to be included in the
>>> program script... #!/usr/bin/env python3
>>>
>>> The other choice is this...
>>>
>>> command="python3 /path/to/program.py"
>>>
>>> (Of course, the Exec command in the .desktop file should match.)
>>>
>>> Is one method better than the other or does it acutally matter?
>>>
>> 
>> I will note that without the shebang (and setting the execute bit), the 
>> program is only executable from the GUI menu, not the command prompt.  I 
>> personally start even GUI programs far more often from a prompt.
>> 
>> To follow Linux conventions you'd put the shebang, make the file 
>> executable, and put the executable somewhere on the PATH.  I'd stick to 
>> those conventions barring a particular reason not to.
> 
> Wildman is talking about launching his program from a menu, so putting 
> it on the PATH is unnecessary.  It may even be a bad idea, depending on 
> exactly what he's done :-)

Yes, that is correct.  My program would be installed using
a deb package manager such as apt and an entry placed in the
desktop menu to launch the program.

Thank you for the reply Rob.

> As to the original question, there shouldn't really be much of a 
> difference.  The original idea of the shebang line invoking env, as far 
> I recall, was that you'd get the "proper" system python3 wherever it had 
> been put rather than something random and possibly malicious.  I guess 
> that means to go for your first option.

Shebang!  Yea, that is the correct term.  All I could think
of was hashbang.  I knew that wasn't quite right.

Yes, I prefer to envoke env in the shebang line instead of
depending on the path.  Paths can change especially in a
multi-user system but env will always know where to find
the executable.

Thank you for your input.  Shebang is the logical answer
with all else being equal.

-- 
 GNU/Linux user #557453
"Setting a good example is a far better way
to spread ideals than through force of arms."
  -Ron Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Launching a Script on the Linux Platform

2019-11-12 Thread Wildman via Python-list
What is the best approach for launching a Python GUI program
on a Linux platform.  The program will be distributed in .deb
format.  So the .deb will contain a menu file as well as a
.desktop file.  The post install script will update the system
menu.

My question is how should the program be executed?  Here are
two choices for the "command=" entry in the menu file...

command="/path/to/program.py"

In this case the hash-bang would have to be included in the
program script... #!/usr/bin/env python3

The other choice is this...

command="python3 /path/to/program.py"

(Of course, the Exec command in the .desktop file should match.)

Is one method better than the other or does it acutally matter?

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT(?)] Ubuntu 18 now defaults to 4-space tabs

2019-09-09 Thread Wildman via Python-list
On Mon, 09 Sep 2019 10:23:57 -0700, Tobiah wrote:

> We upgraded a server to 18.04 and now when I start typing
> a python file (seems to be triggered by the .py extension)
> the tabs default to 4 spaces.  We have decades of code that
> use tab characters, and it has not been our intention to
> change that.
> 
> I found a /usr/share/vim/vim80/indent/python.vim and tried
> moving it out of the way, but the behavior was still there.
> 
> This is more of a vim question perhaps, but I'm already
> subscribed here and I figured someone would know what
> to do.
> 
> 
> Thanks!

A quick search may have revealed your problem.  Look for
an entry named 'expandtab' in vimrc.  You should find
vimrc in /etc/vim or /usr/share/vim or both.  Also if
you have both, one may be a link to the other.

If the entry is there, place a quote mark in front of it
to comment it out...

"set expandtab

If you don't have the entry then it is a different problem
and I would point you back to my original post as my
knowledge of vim is very limited.

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT(?)] Ubuntu 18 now defaults to 4-space tabs

2019-09-09 Thread Wildman via Python-list
On Mon, 09 Sep 2019 10:23:57 -0700, Tobiah wrote:

> We upgraded a server to 18.04 and now when I start typing
> a python file (seems to be triggered by the .py extension)
> the tabs default to 4 spaces.  We have decades of code that
> use tab characters, and it has not been our intention to
> change that.
> 
> I found a /usr/share/vim/vim80/indent/python.vim and tried
> moving it out of the way, but the behavior was still there.
> 
> This is more of a vim question perhaps, but I'm already
> subscribed here and I figured someone would know what
> to do.
> 
> 
> Thanks!

There are quite a few vim users that frequent the alt.os.linux
newsgroups, i.e.;

alt.os.linux
alt.os.linux.debian
alt.os.linux.mint
alt.os.linux.ubuntu

-- 
 GNU/Linux user #557453
The early bird might get the worm but it
is the second mouse that gets the cheese.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: beginner question-very basic

2019-08-11 Thread Wildman via Python-list
On Sun, 11 Aug 2019 12:50:29 -0400, slefkowitz wrote:

> Just getting started with Python.
> 
> Downloaded 3.7.4 rom python.org
> 
> I wrote  program in Notepad, saved it with a ".py" extension.
> 
> What do I do next? How do I execute a program?

I am assuming you are using Windows since you posted with Outlook
and that the python executable is in your path.

Open a cmd window and enter:  python \path\to\program.py

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help with tkinter

2019-08-01 Thread Wildman via Python-list
On Thu, 01 Aug 2019 16:31:02 +0300, adam kabbara wrote:

> Hello I am having trouble with tkinter when I enter the command from tkinter 
> import* I get an error message
> 

What was the error and what version of Python are
you using?

For Python 2 you need... from Tkinter import*

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's wrong on using Popen's communicate method?

2019-07-03 Thread Wildman via Python-list
On Thu, 04 Jul 2019 10:36:36 +1000, Cameron Simpson wrote:

> On 03Jul2019 16:57, Jach Fong  wrote:
>>I have the test0.py below. I expect to see 'abcd' showing in the notepad 
>>window:
>>-
>>import subprocess as sp
>>p0 = sp.Popen('notepad.exe', stdin=sp.PIPE)
>>p0.communicate(input=b'abcd')
>>-
>>But nothing happens. The notepad is completely empty. What have I missed?
>>--Jach
>>
>>PS. I am using python 3.4 on Windows Vista
> 
> Well I am not a Windows person, but in most GUI environments a desktop 
> app such as Notepad does not read from its standard input - it reads 
> keyboard stuff though the GUI interface instead. So it is ignoring your 
> input data - this approach will generally fail with any desktop app on 
> any platform.
> 
> You may need to investigate generating synthetic keystrokes somehow.
> 
> Or alternatively write your data to a text file and hand the name of the 
> text file to notepad as a file to edit.
> 
> Cheers,
> Cameron Simpson 

I block googlegroups so I don't see the original post.  I am
talking to the OP.

Take a look at the SendKeys module.

https://pypi.org/project/SendKeys/

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hiding a progressbar in tkinter

2019-06-26 Thread Wildman via Python-list
On Wed, 26 Jun 2019 17:47:39 +0200, Cecil Westerhof wrote:

> I just started with GUI stuff in tkinter. I have a progressbar, but I
> want it to be only visible when it is used. So I tried the following:
> window = Tk()
> window.title(window_str)
> frame  = Frame(window)
> frame.pack(side = "top", fill = "both", expand = True)
> Button(window, text = button_str, command = select_dir).pack()
> progress = ttk.Progressbar(window, orient = "horizontal", length = 200,
>mode = "determinate")
> progress.pack()
> progress.lower(frame)
> window.mainloop()
> 
> But that does not hide the progressbar. What am I doing wrong?
> 
> I could use pack_forget, but that will change the dimensions of the
> window.

Here is an example using grid_forget().

https://stackoverflow.com/questions/33768577/tkinter-gui-with-progress-bar

Disclaimer:  I have not tested this code and cannot say for certain
that it will work the way you want.

-- 
 GNU/Linux user #557453
"Be vewy vewy qwiwet, I'm hunting wabbits."
  -Elmer Fudd
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Make sure the window title is visible in tkinter

2019-06-26 Thread Wildman via Python-list
On Wed, 26 Jun 2019 15:05:15 +0200, Cecil Westerhof wrote:

>> OK, then I will have to live with it.

I did find some references to a method where you first disable
the Tkinter title bar using overrideredirect(True).  Then you
create a new title bar using a frame and canvas.  You can then
set the font/size for the canvas.

I think you could do it with a label but if you want an icon
and close (X) button, that could be a problem.  IFAIK you can
have only one image on a label.

-- 
 GNU/Linux user #557453
"I am Lrrr! Ruler of the planet Omicron Persei 8!
Can I crash on your couch?"
  -Lrrr
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Make sure the window title is visible in tkinter

2019-06-26 Thread Wildman via Python-list
On Wed, 26 Jun 2019 13:25:15 +0200, Cecil Westerhof wrote:

> I need to write a desktop program. I choose to use tkinter. How can I
> make sure the window title is visible? For example when I have the
> following code:
> from tkinter  import Button, filedialog, Label, messagebox, Tk
> 
> 
> window = Tk()
> window.title('A long window title')
> Button (window, text = 'Short text').pack()
> window.mainloop()
> 
> I see only a part of the 'A', but I would like to see the complete:
> 'A long window title'

According to link below, it is not possible...
"Tkinter has no way of knowing how long the title is on the titlebar."

https://stackoverflow.com/questions/35273690/tkinter-window-not-wide-enough-to-display-window-title

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter on Mac OS crashes python

2019-05-14 Thread Wildman via Python-list
On Tue, 14 May 2019 11:22:54 -0600, Chip Towner wrote:

> I am trying to use tkinter and when I attempt to do so Python crashes.  I am 
> accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda.  The version of 
> TkVersion tells me the version is 8.6 and the Anaconda environment browser 
> tells me it is 8.6.8.
> 
> An example piece of code I am trying to run (pulled from the __init__.py file 
> in the tkinter code installed by Anaconda) is provided below.  The code 
> crashes when tk = tkinter.Tk() is called.  I have traced the crash into this 
> method to a call to _tkinter.create().  The debugger can’t step any further.
> 
> I can provide crash logs if desired. Any help is appreciated.
> 
> import tkinter
> from tkinter.constants import *
> tk = tkinter.Tk()
> frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
> frame.pack(fill=BOTH,expand=1)
> label = tkinter.Label(frame, text="Hello, World")
> label.pack(fill=X, expand=1)
> button = tkinter.Button(frame,text="Exit",command=tk.destroy)
> button.pack(side=BOTTOM)
> tk.mainloop()
> 
> Chip

You might need to add...

from tkinter import Tk

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: variable width widgets in a grid?

2019-02-24 Thread Wildman via Python-list
On Sun, 24 Feb 2019 09:09:22 -0800, Rich Shepard wrote:

> When placing widgets (e.g., Entry, Spinbox) in a grid layout can a length
> (visible width) be specified? For example, a telephone extension is a shorter
> string than the number itself.

The height and width can be specified in the command that
creates the wedget.

> What's a good resource (other than this mail list) for such questions?

http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

> TIA,
> 
> Rich

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: get the terminal's size

2019-01-16 Thread Wildman via Python-list
On Mon, 14 Jan 2019 11:57:33 +, Alex Ternaute wrote:

> Hi there,
> 
> I want to know the number of columns of the terminal where python2 writes 
> it's outputs.
> 
> In a terminal, I type
> $ echo $COLUMNS
> 100
> 
> But in Python, os.getenv("COLUMNS") gets nothing.
> It gets nothing as well if I try to read the output of "echo $COLUMNS" 
> from a subprocess.
> 
> I feel that I'm missing something but what ?
> 
> Looking on the internet for a hint, I see that python3 has an  
> os.get_terminal_size(). 
> Please, is there something similar for python2 ?
> 
> Cheers

I have used this Python2 code with success in Linux...

#!/usr/bin/env python

import fcntl
import os
import struct
import termios

tty = os.open(os.ctermid(), os.O_RDONLY)
ts = struct.unpack("hh", fcntl.ioctl(tty, termios.TIOCGWINSZ, "1234"))
os.close(tty)
print str(ts[1]) + "x" + str(ts[0])

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RAR functionality

2018-11-30 Thread Wildman via Python-list
On Fri, 30 Nov 2018 16:42:06 -0500, Benjamin Schollnick wrote:

> Folks,
> 
> Can anyone explain to me why RAR support isn’t available natively in python?
> 
> We have the zipfile and tarfile modules… 
> 
> Yes, there is rarfile and PaTools but they both rely on RAR being available 
> to shell out to…  
> What is it about RAR files that makes it unreasonable to handle in natively 
> in python?
> Licensing?  Bad rar file design?
> 
>   - Benjamin

RAR is proprietary.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Wildman via Python-list
On Sun, 25 Nov 2018 22:43:10 +0530, srinivasan wrote:

> Dear Python Experts Team,
> 
> As am newbie still learning the python syntax from past 2 weeks, Excuse me,
> If this might be silly question, As I am trying to execute shell command
> (ie, nmcli) using "subprocess.Popen".
> 
> *return proc.strip().decode("utf-8")*

return proc.decode("utf-8").strip()

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Have I Been Banned?

2018-11-20 Thread Wildman via Python-list
On Tue, 20 Nov 2018 16:39:39 +, Jon Ribbens wrote:

> On 2018-11-20, Wildman  wrote:
>> In the past I have participated in the group without any
>> problems.  I access the forum through the usenet mirror
>> and I am still using the same newsreader and account.
>> Recently I made some followup posts to the group and they
>> never showed up.  Have I been banned?  If so, I would
>> appreciate it to know why?
> 
> If you mean you made posts to the comp.lang.python group and they did
> not show up on your news server then the problem is either at your
> end or with your news server - unlike the mailing list, the group is
> unmoderated and therefore nobody can be banned from it.

Yes, I make posts to comp.lang.python.  My newsreader's log says the
posts are accepted by the server.  I will contact Giganews to see if
they can shed some light on the subject.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Have I Been Banned?

2018-11-20 Thread Wildman via Python-list
In the past I have participated in the group without any
problems.  I access the forum through the usenet mirror
and I am still using the same newsreader and account.
Recently I made some followup posts to the group and they
never showed up.  Have I been banned?  If so, I would
appreciate it to know why?

Of course I am not sure if this post will make it to the
server.

-- 
 GNU/Linux user #557453
Restricted area!  Authorized trespassers only.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread Wildman via Python-list
I tried posting this already but it didn't make it.  I am
trying again...

On Tue, 13 Nov 2018 01:07:06 +0530, srinivasan wrote:

> Dear Python Experts,
> 
> *First method:*
> 
> I need to get the IP address basically the gateway IP

I am assuming your platform is Linux.  If I am incorrect then
ignore this post.

The code below reads /proc/net/route to obtain the gateway and
then prints it.  It can be run as-is from a terminal.

#
#!/usr/bin/env python

import socket
import struct

def get_gateway_ip():
try:
with open("/proc/net/route", "r") as f:
route = f.readlines()
except IOError:
return None
for line in route:
fields = line.strip().split()
if fields[1] != "" or not int(fields[3], 16) & 2:
continue
gateway = socket.inet_ntoa(struct.pack(" GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem: Need galileo running on debian wheezy

2018-03-01 Thread Wildman via Python-list
On Thu, 01 Mar 2018 13:44:27 -0500, Gene Heskett wrote:

> I know its supposed to be in the debian stretch repo's.
> 
> I've been told to get a fitbit, but they don't support linux of any 
> flavor, and that leaves galileo as the possible solution?
> 
> So how should I proceed since the only stretch machine I have ATM is an 
> arm64, aka a rock64.
>  
> -- 
> Cheers, Gene Heskett

I would suggest to download it from stretch's repo
and open it with gdebi.  It will tell you if the
depends are met.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil

2018-02-27 Thread Wildman via Python-list
On Tue, 27 Feb 2018 19:29:50 -0500, Larry Martell wrote:

> Trying to install psutil (with pip install psutil) on Red Hat EL 7.
> It's failing with:
> 
> Python.h: No such file or directory
> 
> Typically that means the python devel libs are not installed, but they are:
> 
> [root@liszt ~]# yum install python-devel
> Package python-devel-2.7.5-58.el7.x86_64 already installed and latest version
> Nothing to do
> 
> Anyone have any idea what to try next?

I am not familiar with Red Hat and the RPM package
system but on my Debian based system it is in the
repository as an installable package.  The package
names are python-psutil and python3-psutil.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to only get \n for newline without the single quotes?

2018-02-24 Thread Wildman via Python-list
On Sat, 24 Feb 2018 11:41:32 -0600, Peng Yu wrote:

> I would like to just get the escaped string without the single quotes.
> Is there a way to do so? Thanks.
> 
 x='\n'
 print repr(x)
> '\n'

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x='/n'
>>> print(repr(x))
'/n'
>>> print(repr(x).strip("'"))
/n
>>> 

Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x='/n'
>>> print repr(x)
'/n'
>>> print repr(x).strip("'")
/n
>>> 

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 10:55:28 +1100, Chris Angelico wrote:

> The given homepage URL is
> http://alastairs-place.net/projects/netifaces/ - is that the right
> one?
> 
> ChrisA

Yes, that is the right one.  Now I'm feeling a little stupid.
I should have remembered that many python library package
names start with python- or python3-. 

Problem solved.  A thousand thank-you's.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 05:31:27 +1100, Chris Angelico wrote:

> On Tue, Feb 20, 2018 at 3:49 AM, Wildman via Python-list
> <python-list@python.org> wrote:
>> On Mon, 19 Feb 2018 12:32:49 +, Rhodri James wrote:
>>
>>> On 18/02/18 16:18, Wildman via Python-list wrote:
>>>>> But that's only going to show one (uplink) address. If I needed to get
>>>>> ALL addresses for ALL network adapters, I'd either look for a library,
>>>>> and if one wasn't easily found, I'd shell out to the "ip" command and
>>>>> parse its output.:)
>>>>>
>>>> I considered using the "ip" command but I prefer not to
>>>> depend on external programs if I can get around it.  I
>>>> know that might be considered silly but that's just me.
>>>
>>> It's not silly at all, but for Linux networking it might be the best
>>> idea.  I believe in theory you are supposed to use libnl (in some
>>> suitable wrapping), but my experience with that is that it is badly
>>> documented and horrendously unreliable.
>>
>> It looks like libnl would do what I want but there is
>> a problem.  When finished, my program will be released
>> in the form of a Debian (*.deb) package and used by,
>> for the most part, 'average' Linux users.  These are
>> people that know their way around Linux but know
>> nothing or very little about Python.  Installing a
>> package using pip by them is pretty much out of the
>> question.  The system's package manager must be able
>> to handle the program's dependencies so third-party
>> packages are out of the question.
>>
>> But thanks for the suggestion.
> 
> If you're distributing it as a .deb, you don't want to use pip to grab
> additional libraries. Ideally, you'd want the library to *also* be
> available through the package manager, which would mean you can simply
> record it as a dependency. If it's not... it's not gonna be easy.
> 
> ChrisA

Yes, you are correct.  Third-party pip packages are always
a no-no.

Speaking of which, there is a library called Netifaces that
will easily do exactly what I want with a few lines of code.
But, it is not to be found in any Linux distro's repository
that I can find.  Oh well...

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 05:39:15 +1100, Chris Angelico wrote:

> On Tue, Feb 20, 2018 at 3:53 AM, Wildman via Python-list
> <python-list@python.org> wrote:
>> On Tue, 20 Feb 2018 02:26:19 +1100, Chris Angelico wrote:
>>
>>> * Opaque IOCTLs
>>
>> Would you mind to elaborate a little about your
>> concerns?
> 
> Look at your original code: it's impossible to figure out what it's
> doing or whether it's doing it correctly. "Opaque" in this context
> means that you can't grok the code without external help. This is a
> code smell, and a strong indication that you're "fiddling" in stuff
> way lower level than you normally want to be working with. It's
> usable, but it's dirty and leaves everything up to you (do you know
> for sure, for instance, if this is backward compatible?
> Cross-platform?), and that makes it comparable to depending on an
> external program.
> 
> ChrisA

I understand and I agree for the most part.  It does concern
me that I don't understand the code.  Anytime in Linux you
start poking around things at kernel level, you need your
eyes to be wide open.  However, to me it looks like the
code is only quarying ioctl and not trying to change any-
thing.  If this is true, there is no problem.

For the issue of backward compatibility, there are good
people on a few of the Linux newsgroups that are willing
to test code snippets for me.  I can get a wide range of
distros, desktops and kernel versions.  And of course
different python3 versions.  I know it is impossible
to write code that will be guaranteed to run on all
conditions.  But the test results I get will or should
let me know right off if there are glaring problems.

As far as cross-platform goes, that is not an issue.
Every thing I do is targeted for the Linux platform.

I will keep "ip" in mind as a backup plan.  As a novice
Python programmer, I am looking at the amount of code
it will take to parse ip's output compared to the few
lines of code it takes to call ioctl.

I really appreciate your insight.  Thank you.

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Tue, 20 Feb 2018 02:26:19 +1100, Chris Angelico wrote:

> * Opaque IOCTLs

Would you mind to elaborate a little about your
concerns?

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-19 Thread Wildman via Python-list
On Mon, 19 Feb 2018 12:32:49 +, Rhodri James wrote:

> On 18/02/18 16:18, Wildman via Python-list wrote:
>>> But that's only going to show one (uplink) address. If I needed to get
>>> ALL addresses for ALL network adapters, I'd either look for a library,
>>> and if one wasn't easily found, I'd shell out to the "ip" command and
>>> parse its output.:)
>>>
>> I considered using the "ip" command but I prefer not to
>> depend on external programs if I can get around it.  I
>> know that might be considered silly but that's just me.
> 
> It's not silly at all, but for Linux networking it might be the best 
> idea.  I believe in theory you are supposed to use libnl (in some 
> suitable wrapping), but my experience with that is that it is badly 
> documented and horrendously unreliable.

It looks like libnl would do what I want but there is
a problem.  When finished, my program will be released
in the form of a Debian (*.deb) package and used by,
for the most part, 'average' Linux users.  These are
people that know their way around Linux but know
nothing or very little about Python.  Installing a
package using pip by them is pretty much out of the
question.  The system's package manager must be able
to handle the program's dependencies so third-party
packages are out of the question.

But thanks for the suggestion.

-- 
 GNU/Linux user #557453
"There are only 10 types of people in the world...
those who understand Binary... and those who don't."
  -Spike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-18 Thread Wildman via Python-list
On Sun, 18 Feb 2018 20:51:18 +1100, Chris Angelico wrote:

> On Sun, Feb 18, 2018 at 4:35 AM, Wildman via Python-list
> <python-list@python.org> wrote:
>> Thanks to Chris and Ben.  Your suggestions were slightly
>> different but both worked equally well, although I don't
>> understand how that can be so.
>>
>>> struct.pack('256s', ifname[:15].encode('ascii'))
>>> struct.pack('256s', ifname.encode('ascii'))
> 
> Those two will be identical for short interface names, but the first
> form will truncate a longer name before encoding. I don't know what
> the ioctl will do with a really long ifname, so it's probably worth
> hanging onto the [:15] slicing.

Since the interfaces are named by the (Linux) system,
I don't think long interface names will be a problem.
Names are used like lo, eth0, wlan0, ppp0, vmnet8, etc.
But, I will keep the [:15} slicing just in case.

>> I was looking for a reliable way to determine the IP addy
>> for a given network adapter.  That is what the code does
>> but I don't understand how it does it either.
>>
>> Thanks again.  I will continue to research and study the
>> code in the hope I will understand it.
> 
> Ah, makes sense. I'd probably do something like this:
> 
>>>> import socket
>>>> s = socket.socket(type=socket.SOCK_DGRAM)
>>>> s.connect(("8.8.8.8", 53))
>>>> s.getsockname()[0]
> '192.168.0.19'

Brief background...  I am working on a project that reports
Linux system info and lan is part of it.  To start with I
was using code similar to the above but, with the help of
a few testers in some of the Linux newsgroups, I found it
did not work correctly in all situations such as 'live'
sessions.  So I started looking for an alternative.

> But that's only going to show one (uplink) address. If I needed to get
> ALL addresses for ALL network adapters, I'd either look for a library,
> and if one wasn't easily found, I'd shell out to the "ip" command and
> parse its output. :)
> 
> ChrisA

I considered using the "ip" command but I prefer not to
depend on external programs if I can get around it.  I
know that might be considered silly but that's just me.

Thanks for your input.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 Conversion

2018-02-18 Thread Wildman via Python-list
Thanks to Chris and Ben.  Your suggestions were slightly
different but both worked equally well, although I don't
understand how that can be so.

> struct.pack('256s', ifname[:15].encode('ascii'))
> struct.pack('256s', ifname.encode('ascii'))

I was looking for a reliable way to determine the IP addy
for a given network adapter.  That is what the code does
but I don't understand how it does it either.

Thanks again.  I will continue to research and study the
code in the hope I will understand it.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2 to 3 Conversion

2018-02-16 Thread Wildman via Python-list
I have a bit of code I found on the web that will return
the ip address of the named network interface.  The code
is for Python 2 and it runs fine.  But, I want to use the
code with Python 3.  Below is the code followed by the error
message.  Suggestions appreciated.

#!/usr/bin/env python3

import socket
import fcntl
import struct

def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915,  # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
print(get_ip_address("eth0"))
print(get_ip_address("lo"))


Traceback (most recent call last):
  File "./test.py", line 14, in 
print(get_ip_address("eth0"))
  File "./test.py", line 12, in get_ip_address
struct.pack('256s', ifname[:15])
struct.error: argument for 's' must be a bytes object

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Wildman via Python-list
On Sun, 28 Jan 2018 15:04:26 +, Steven D'Aprano wrote:

> I'm seeing this annoying practice more and more often. Even for trivial 
> pieces of text, a few lines, people post screenshots instead of copying 
> the code.
> 
> Where has this meme come from? It seems to be one which inconveniences 
> *everyone* involved:
> 
> - for the sender, instead of a simple copy and paste, they have to take a 
> screen shot, possibly trim the image to remove any bits of the screen 
> they don't want to show, attach it to their email or upload it to an 
> image hosting site;
> 
> - for the receiver, you are reliant on a forum which doesn't strip 
> attachments, or displays externally hosted images; the visually impaired 
> are excluded from using a screen reader; and nobody can copy or edit the 
> given text.
> 
> It is as if people are deliberately inconveniencing themselves in order 
> to inconvenience the people they are asking to help them.
> 
> With the exception of one *exceedingly* overrated advantage, namely the 
> ability to annotate the image with coloured lines and circles and 
> squiggles or other graphics (which most people don't bother to do), this 
> seems to me to be 100% counter-productive for everyone involved. Why has 
> it spread and why do people keep doing it?
> 
> I don't want to be the old man yelling "Get Of My Lawn!" to the cool 
> kids, but is this just another sign of the downward spiral of programming 
> talent? Convince me that there is *some* justification for this practice. 
> Even a tiny one.
> 
> (The day a programmer posts a WAV file of themselves reading their code 
> out aloud, is the day I turn my modem off and leave the internet forever.)

I can think of no justification for it.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: error from Popen only when run from cron

2018-01-27 Thread Wildman via Python-list
On Sat, 27 Jan 2018 10:58:36 -0500, Larry Martell wrote:

> I have a script that does this:
> 
> subprocess.Popen(['service', 'some_service', 'status'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
> 
> When I run it from the command line it works fine. When I run it from
> cron I get:
> 
> subprocess.Popen(['service', 'some_service', 'status'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>   File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
> errread, errwrite)
>   File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
> raise child_exception
> OSError: [Errno 2] No such file or directory
> 
> Anyone have any clue as to what file it's complaining about? Or how I
> can debug this further?

Cron provides this as $PATH:  /usr/bin;/usr/sbin

>From within a terminal enter:  whereis service

If service is not in Cron's $PATH, that is your problem.
Adding the complete path to 'service' in the script
should fix things.

If service is in Cron's $PATH, I have no further ideas.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ttk.Notebook Tabs Question

2017-09-15 Thread Wildman via Python-list
On Fri, 15 Sep 2017 20:45:20 +0100, MRAB wrote:

> On 2017-09-15 16:24, Wildman via Python-list wrote:
>> On Fri, 15 Sep 2017 06:09:21 +0400, Abdur-Rahmaan Janhangeer wrote:
>> 
>>> try
>>> widget["width"] it returns string
>>> then mult by no. of tabs
>> 
>> Since the tabs are displaying text, I believe the width
>> would be returned as characters or letters like a Button
>> or Text widget.  I need pixels.
>> 
> Why assume that the width is returned as characters? Why not try it?

If I set the width of the tabs, the width is in characters
so I expected it to be the same.

style = ttk.Style()
style.theme_create( "MyStyle", parent="alt", settings={
"TNotebook": {"configure": {"tabmargins": [2, 5, 2, 0] } },
"TNotebook.Tab": {"configure": {"padding": [0,0], "width": [7]}, }})
style.theme_use("MyStyle")

Also, I tried "widget["width"] and it returns 0.  Same
for height.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ttk.Notebook Tabs Question

2017-09-15 Thread Wildman via Python-list
On Fri, 15 Sep 2017 06:09:21 +0400, Abdur-Rahmaan Janhangeer wrote:

> try
> widget["width"] it returns string
> then mult by no. of tabs

Since the tabs are displaying text, I believe the width
would be returned as characters or letters like a Button
or Text widget.  I need pixels.

Another problem is that the tabs are different widths.

I am going to experiment with the possibility of using
images in place of the text.  Then I believe the width
would be returned in pixels.

Thanks for the reply.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With Gdk.Display

2017-08-16 Thread Wildman via Python-list
On Wed, 16 Aug 2017 14:33:27 -0500, Wildman wrote:

> On Wed, 16 Aug 2017 19:11:16 +0100, MRAB wrote:
> 
>> On 2017-08-16 18:57, Wildman via Python-list wrote:
>>> I am working on a program for the Linux platform that
>>> reports system information.  The program reports screen
>>> information, number of monitors, resolution of each one
>>> and the total resolution.  It does it using a couple of
>>> external utils, Xrandr and Xdpyinfo.  It is my goal to
>>> replace the existing code with a python solution without
>>> depending on the external programs.
>>> 
>>> With the help of a code snippet I found, I came up with
>>> this but it only reports the resolution of the primary
>>> monitor...
>>> 
>>> #! /usr/bin/env python3
>>> 
>>> import gi
>>> gi.require_version('Gdk', '3.0')
>>> from gi.repository import Gdk
>>> 
>>> display = Gdk.Display.get_default()
>>> pm = display.get_primary_monitor()
>>> geo = pm.get_geometry()
>>> w = geo.width
>>> h = geo.height
>>> print(w,h)
>>> 
>>> 
>>> I know that the number of monitors can be obtained by
>>> using...
>>> 
>>> mc = Gdk.Display.get_n_monitors(display)
>>> 
>>> Then to get each monitor, this can be used...
>>> 
>>> monitor = Gdk.Display.get_monitor(display, monitor_num)
>>> 
>>> My problem is that I can't find any information on how
>>> "monitor_num" is obtained.  The only thing I have been
>>> able to find out is that it is an integer.  Can anybody
>>> point me in the right direction?  Much appreciated.
>>> 
>> If get_n_monitors tells you how many monitors there are, isn't 
>> monitor_num just an index (0, 1, 2, ...)?
> 
> I don't know.  The documentation doesn't say.  That is
> something I can test that I hadn't thought of.  I hope
> you are right.  It would be nice if it was that simple.
> Thanks.

In case anyone is interested that was the answer.
Thanks again MRAB.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With Gdk.Display

2017-08-16 Thread Wildman via Python-list
On Wed, 16 Aug 2017 19:11:16 +0100, MRAB wrote:

> On 2017-08-16 18:57, Wildman via Python-list wrote:
>> I am working on a program for the Linux platform that
>> reports system information.  The program reports screen
>> information, number of monitors, resolution of each one
>> and the total resolution.  It does it using a couple of
>> external utils, Xrandr and Xdpyinfo.  It is my goal to
>> replace the existing code with a python solution without
>> depending on the external programs.
>> 
>> With the help of a code snippet I found, I came up with
>> this but it only reports the resolution of the primary
>> monitor...
>> 
>> #! /usr/bin/env python3
>> 
>> import gi
>> gi.require_version('Gdk', '3.0')
>> from gi.repository import Gdk
>> 
>> display = Gdk.Display.get_default()
>> pm = display.get_primary_monitor()
>> geo = pm.get_geometry()
>> w = geo.width
>> h = geo.height
>> print(w,h)
>> 
>> 
>> I know that the number of monitors can be obtained by
>> using...
>> 
>> mc = Gdk.Display.get_n_monitors(display)
>> 
>> Then to get each monitor, this can be used...
>> 
>> monitor = Gdk.Display.get_monitor(display, monitor_num)
>> 
>> My problem is that I can't find any information on how
>> "monitor_num" is obtained.  The only thing I have been
>> able to find out is that it is an integer.  Can anybody
>> point me in the right direction?  Much appreciated.
>> 
> If get_n_monitors tells you how many monitors there are, isn't 
> monitor_num just an index (0, 1, 2, ...)?

I don't know.  The documentation doesn't say.  That is
something I can test that I hadn't thought of.  I hope
you are right.  It would be nice if it was that simple.
Thanks.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Request Help With Gdk.Display

2017-08-16 Thread Wildman via Python-list
I am working on a program for the Linux platform that
reports system information.  The program reports screen
information, number of monitors, resolution of each one
and the total resolution.  It does it using a couple of
external utils, Xrandr and Xdpyinfo.  It is my goal to
replace the existing code with a python solution without
depending on the external programs.

With the help of a code snippet I found, I came up with
this but it only reports the resolution of the primary
monitor...

#! /usr/bin/env python3

import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk

display = Gdk.Display.get_default()
pm = display.get_primary_monitor()
geo = pm.get_geometry()
w = geo.width
h = geo.height
print(w,h)


I know that the number of monitors can be obtained by
using...  

mc = Gdk.Display.get_n_monitors(display)

Then to get each monitor, this can be used...

monitor = Gdk.Display.get_monitor(display, monitor_num)

My problem is that I can't find any information on how
"monitor_num" is obtained.  The only thing I have been
able to find out is that it is an integer.  Can anybody
point me in the right direction?  Much appreciated.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recent Spam problem

2017-07-27 Thread Wildman via Python-list
On Tue, 25 Jul 2017 21:44:22 +, Grant Edwards wrote:

> On 2017-07-25, Wildman via Python-list <python-list@python.org> wrote:
> 
>> The posts are being made through Google Groups.  Forwarding
>> the posts with headers to groups-ab...@google.com might help.
> 
> I never has in the past.  I (and many others) have for years and years
> been plonking all posts made through Google Groups.  Trust me, you'll
> not miss out on anything worthwile. :)
> 
>> I have sent a couple but if everyone here did it maybe Google will
>> pay attention and do something.
> 
> They won't.
> 
> Just configure your .score file (or bogofilter or spamassassin or
> whatever) to throw out all posts that have a Message-ID: header field
> that ends in 'googlegroups.com'.  That, grashopper, is the path to
> serenity.

In the past I never used a 'kill file' so I didn't
consider it.  However, I took your advice and created
the score file and I will say the path to serenity is
sweet.  Thank you.

-- 
 GNU/Linux user #557453
"SERENITY NOW! SERENITY NOW!"
  -Frank Costanza
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new here and i need your help please

2017-07-25 Thread Wildman via Python-list
On Tue, 25 Jul 2017 00:48:25 -0700, yasirrbadamasi wrote:

> I have never execute any program before using python and a task was given to 
> me by my teacher 
> ~ to write a python program to print my details and store in a third party 
> variables.
> ~ the details include name, age, height, status. so please your help is 
> highly needed, thanks

Read the material and write some code the best you can
and post it here.  Someone will try to help you.  No
one here is going to do your homework for you.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recent Spam problem

2017-07-25 Thread Wildman via Python-list
On Mon, 24 Jul 2017 23:01:43 -0700, Paul Rubin wrote:

> Rustom Mody  writes:
>> Since spammers are unlikely to be choosy about whom they spam:
>> Tentative conclusion: Something about the USENET-ML gateway is more leaky
>> out here than elsewhere
> 
> It could be a sort-of DOS attack by some disgruntled idiot.  I wonder if
> the email address in those spam posts actually works.  Then there's the
> weird Italian rants.  No idea about those.

The posts are being made through Google Groups.  Forwarding
the posts with headers to groups-ab...@google.com might help.
I have sent a couple but if everyone here did it maybe
Google will pay attention and do something.  The same goes
for our Italian "friend".

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syntax error for simple script

2017-06-26 Thread Wildman via Python-list
On Tue, 27 Jun 2017 03:31:57 +1000, Chris Angelico wrote:

> On Tue, Jun 27, 2017 at 1:16 AM, Ben S. via Python-list
>  wrote:
>> I installed Python v3.6.1 on win 7. Afterwards I tried to execute the 
>> following simple python script from webpage 
>> http://www.pythonforbeginners.com/code-s...me-script/:
> 
> Can you provide the complete link please? Something seems to have
> ellipsized it. Whatever the page is, it needs to be updated to be
> Python 3 compatible.
> 
> ChrisA

Here it is...

http://www.pythonforbeginners.com/code-snippets-source-code/date-and-time-script/

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.getlogin() Error

2017-05-06 Thread Wildman via Python-list
On Fri, 05 May 2017 11:30:41 -0700, 20/20 Lab wrote:

> I'm not sure if this will help you, but I found some stuff on accident 
> looking at something related.
> 
> Not sure if it will help, but looked promising
> 
> https://github.com/parmentelat/apssh/issues/1
> 
> ==Some snippets from the page
> 
>  From the os.getlogin() docs: "Returns the user logged in to the 
> controlling terminal of the process." Your script does not have a 
> controlling terminal when run from cron. The docs go on to suggest: "For 
> most purposes, it is more useful to use the environment variable LOGNAME 
> to find out who the user is, or pwd.getpwuid(os.getuid())[0] to get the 
> login name of the currently effective user id."
> 
> 
> I suggest you to replace os.getlogin with:
> 
> import pwd
> import os
> 
> getlogin = lambda: pwd.getpwuid(os.getuid())[0]
> default_username = getlogin()

I appreciate the reply but the problem has been fixed.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does Python want to read /proc/meminfo

2017-05-06 Thread Wildman via Python-list
On Fri, 05 May 2017 23:54:20 -0500, Ian Pilcher wrote:

> I am trying to write an SELinux policy to confine a simple service that
> I have written in Python, and I'm trying to decide whether to allow or
> dontaudit various denials.
> 
> To start, I've reduced my service to the simplest case:
> 
>#!/usr/bin/python
> 
>import sys
> 
>sys.exit()
> 
> Running this program in a confined domain generated the following
> denial:
> 
> avc:  denied  { read } for  pid=2024 comm="denatc" name="meminfo" 
> dev="proc" ino=4026532028 scontext=system_u:system_r:denatc_t:s0 
> tcontext=system_u:object_r:proc_t:s0 tclass=file
> 
> The program does continue on and exit cleanly, so it doesn't seem to
> strictly require the access.
> 
> Does anyone know why Python is trying to access this file, or what
> functionality I might be missing if I don't allow the access?

The obvious answer is Python is checking to see if there is
enough ram and/or stack space.  I'm not sure why the access
was denied tho.  Something here might be of help...

https://lists.gt.net/gentoo/hardened/259011

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.getlogin() Error

2017-05-04 Thread Wildman via Python-list
On Fri, 05 May 2017 09:58:02 +1000, Chris Angelico wrote:

> On Fri, May 5, 2017 at 9:50 AM, Wildman via Python-list
> <python-list@python.org> wrote:
>> I'm afraid that won't work.  The user environment is different
>> than root.  A different set of variables.  However you have
>> given me a possible workaround.  You can't create a variable
>> for root unless you are root so that approach is out.  But
>> it might be possible to create the variable for the user
>> and access it as root.  I don't have a lot of experience
>> using os.environ, but I am going to at it closer.
> 
> When you start a subprocess, it inherits your environment. So you can
> create an environment variable for yourself, then start the other
> process.

I solved this problem by passing the user name to the second
instance as a command line argument.  Works perfectly.  It
escapes me why I didn't think of this sooner.  I solved the
os.login problem by not using os.login, since I no longer
need it. :-)

> But read Cameron's cautionary notes and basically just don't do this.
> 
> ChrisA

It has been my experience that Linux users tend to be a little
more conscious of security matters and know what the implications
are when doing anything as root.  I expect the user will know the
risks if they choose to restart the program as root.  I believe
in user choice.

Thanks again for your replies.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.getlogin() Error

2017-05-04 Thread Wildman via Python-list
On Fri, 05 May 2017 09:00:58 +1000, Cameron Simpson wrote:

> On 04May2017 15:03, Wildman  wrote:
> 
>>The program installs using the Debian package system (.deb) and an
>>entry is created in the Applications Menu.  The strange thing is
>>that the crash only occurs when the program is run from the menu.
>>If I open a terminal and run the program from there, the program
>>runs fine.
> 
> And this supports that.
> 
> getlogin is not magic, and can be overused. The Python docs say "Return the 
> name of the user logged in on the controlling terminal of the process." 
> Clearly 
> that will fail.
> 
> When you start from a terminal, your command will have that as its 
> controlling 
> terminal unless it has gone out of its way not to. When you start from a 
> menu, 
> usually that menu system will not be associated with a terminal. In this case 
> you need to fall back on other methods of figuring out "who is logged in".

What I don't understand is why the program will run from the menu
on some Linux distros and not others.  I might need to take a
closer look at the structure of the .desktop file used to launch
my program.  Thanks.

> You should also _minimise_ the time and work your program does as root. Along 
> the lines of:
> 
>   ... program invoked setuid ...
>   look up os.getuid() to find the uid of the invoker
>   read as little as possible of the privileged info (i.e. shadow) as required
>   os.setuid() BACK TO THE ORIGINAL USER SO YOU ARE NO LONGER ROOT
>   ... do everything else ...

This is interesting.  Will do some experimenting.

> Part of your problem is that "who is the currently logged in user" is a 
> nebulous idea. Supposing you were to address the lack of controlling terminal 
> by seeing who is logged into the console. That is a little trusting. 
> Supposing 
> _you_ are logged into the console, running X11. And while so, _I_ ssh into 
> your 
> machine and run your program without a controlling terminal. Then your 
> program 
> will _mistakenly_ presume the logged in user is _you_ (because, after all, 
> you're logged in), and report _your_ information to _me_.
> 
> For all that setuid programs have their own security issues, at least they 
> _know_ who they were invoked by from os.getuid(), without playing insecure 
> guessing games around "who is logged in". Because the latter is not 
> equivalent 
> to "whose information should I access?"
> 
> I hope this points a way forward.
> 
> Personally I would usually resist accessing information not available as the 
> user, and avoid the need to run as root at all.
> 
> Cheers,
> Cameron Simpson 

I appreciate the advice and will consider it.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.getlogin() Error

2017-05-04 Thread Wildman via Python-list
On Fri, 05 May 2017 08:31:15 +1000, Chris Angelico wrote:

> On Fri, May 5, 2017 at 8:18 AM, Wildman via Python-list
> <python-list@python.org> wrote:
>> I am using pkexec to restart so $SUDO_USER is not set.  For some
>> reason sudo, su and su-to-root will freeze the first instance of
>> the program and not let it close until the second instance closes.
>> I have tried every method I can find to launch them and pkexec
>> is the only one that works correctly.
>>
>> Thanks for the reply.
> 
> Ah, okay. I wonder if you can do the same thing? Just before you
> invoke pkexec, create an environment variable with the current user
> credentials. Then pkexec back to yourself, and look in the
> environment.
> 
> ChrisA

I'm afraid that won't work.  The user environment is different
than root.  A different set of variables.  However you have
given me a possible workaround.  You can't create a variable
for root unless you are root so that approach is out.  But
it might be possible to create the variable for the user
and access it as root.  I don't have a lot of experience
using os.environ, but I am going to at it closer.

Thanks.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.getlogin() Error

2017-05-04 Thread Wildman via Python-list
On Fri, 05 May 2017 07:46:32 +1000, Chris Angelico wrote:

> On Fri, May 5, 2017 at 6:03 AM, Wildman via Python-list
> <python-list@python.org> wrote:
>> I will try to explain...
>> The program reports system information based on the user's name.
>> Things such as passwd, groups and shadow info.  However, the
>> program must have elevated privileges to get the shadow info so
>> the program has the option to 'restart as root' so the shadow
>> information will be obtainable.
>>
>> If the program is restarting as root, the work-arounds report
>> the user as 'root'.  Then the system information for passwd,
>> groups and shadow will be reported for 'root' and not the
>> user that ran the program.  The actual user name that ran
>> the program is needed for the program to report correct
>> information.
>>
>> It seems that only os.getlogin() reports the true user name no
>> matter if the program is run as a normal user or restarted as
>> root.
>>
>> Is there a way to get the actual user name or is there a fix
>> or a better work-around for the os.getlogin() function?
> 
> That depends on exactly how the program "restarts as root". One very
> common way to do this is to invoke itself through sudo(1). If that's
> how you're flipping yourself to root, check os.environ["SUDO_USER"] or
> os.environ["SUDO_UID"], both of which will be set by sudo before it
> invokes the program.
> 
> ChrisA

I am using pkexec to restart so $SUDO_USER is not set.  For some
reason sudo, su and su-to-root will freeze the first instance of
the program and not let it close until the second instance closes.
I have tried every method I can find to launch them and pkexec
is the only one that works correctly.

Thanks for the reply.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


os.getlogin() Error

2017-05-04 Thread Wildman via Python-list
I wrote a Linux only GUI program using Tk that reports various system
information using a tabbed Notebook.  I have tested the program on
Debian, SoldyX and MX-15 and the program runs perfectly.

I tried testing on Mint and Ubuntu and the program would crash.  The
GUI would appear briefly and disappear.  On Ubuntu a crash report was
created so I was able to figure out what was going on.  It had the
traceback and showed that os.getlogin threw an error.  This is from
the crash report:

PythonArgs: ['/opt/linfo-tk/linfo-tk.py']
Traceback:
 Traceback (most recent call last):
   File "/opt/linfo-tk/linfo-tk.py", line 1685, in 
 app = Window(root)
   File "/opt/linfo-tk/linfo-tk.py", line 1393, in __init__
 txt = function()
   File "/opt/linfo-tk/linfo-tk.py", line 316, in userinfo
 user = os.getlogin()
 OSError: [Errno 25] Inappropriate ioctl for device

The program installs using the Debian package system (.deb) and an
entry is created in the Applications Menu.  The strange thing is
that the crash only occurs when the program is run from the menu.
If I open a terminal and run the program from there, the program
runs fine.

I found a little info on the web about this but it was not clear
whether it is a bug in Linux or a bug in the os module.  I also
found a couple of work-arounds but neither of them will work for
my purposes.

user = pwd.getpwuid(os.getuid())[0]
user = getpass.getuser()

I will try to explain...
The program reports system information based on the user's name.
Things such as passwd, groups and shadow info.  However, the
program must have elevated privileges to get the shadow info so
the program has the option to 'restart as root' so the shadow
information will be obtainable.

If the program is restarting as root, the work-arounds report
the user as 'root'.  Then the system information for passwd,
groups and shadow will be reported for 'root' and not the
user that ran the program.  The actual user name that ran
the program is needed for the program to report correct
information.

It seems that only os.getlogin() reports the true user name no
matter if the program is run as a normal user or restarted as
root.

Is there a way to get the actual user name or is there a fix
or a better work-around for the os.getlogin() function?

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bigotry and hate speech on the python mailing list

2017-04-18 Thread Wildman via Python-list
On Wed, 19 Apr 2017 08:34:03 +1000, Chris Angelico wrote:

> On Wed, Apr 19, 2017 at 8:28 AM, Ben Finney  
> wrote:
>> Chris Angelico  writes:
>>
>>> The charge has been examined and dropped. Steven did not violate the
>>> CoC. Please stop talking as if he has. He *was accused of* violating
>>> it, and then found innocent.
>>
>> Which post are you referring to (can you provide a URL)? I'd like to see
>> who came to that conclusion, what their wording was, and what their
>> authority was to do so.
> 
> I was referring to your post, in which a fairly solid argument was
> made for there being no guilt. Maybe you don't have any specific
> authority, but until someone actually acts in a moderatorial role,
> solid arguments are plenty authoritative enough for most of us.
> Particularly for the newsgroup people, where there is no central
> authority at all.
> 
> ChrisA

I believe the lack of moderator action supports the
conclusion that the CoC was not violated.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bigotry and hate speech on the python mailing list

2017-04-18 Thread Wildman via Python-list
On Wed, 19 Apr 2017 00:19:10 +1000, Chris Angelico wrote:

> On Wed, Apr 19, 2017 at 12:01 AM, Rurpy via Python-list
>  wrote:
>> Whether you like it or not this list has a CoC governing it.
>> Discussions about appropriate posts ARE on-topic.
>> If you want a list where anyone can say any vile racist thing
>> they want, there are plenty of them on the internet, you dont
>> belong here.
>> I have nothing personal against Steven.  He called someone out
>> for being bigoted, then repeated the exact same offense himself.
> 
> The charge has been examined and dropped. Steven did not violate the
> CoC. Please stop talking as if he has. He *was accused of* violating
> it, and then found innocent.
> 
> ChrisA

You are just confusing the issue with facts. 

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bigotry and hate speech on the python mailing list

2017-04-18 Thread Wildman via Python-list
On Tue, 18 Apr 2017 03:28:32 +, Rurpy wrote:

> On 04/17/2017 08:19 PM, Wildman via Python-list wrote:
>> On Tue, 18 Apr 2017 08:23:34 +1000, Ben Finney wrote:
>>> Paul Rubin <no.email@nospam.invalid> writes:
>>>> Rurpy <ru...@yahoo.com> writes:
>>>>> A couple weeks ago a frequent poster here (Steve D'Aprano
>>>>> <steve+pyt...@pearwood.info>) called another participant an "ugly
>>>>> american"
>>>>
>>>> Oh stop trolling.
>>>
>>> Paul, that is uncalled for. The charge of bigotry is not to be lightly
>>> dismissed, and we do want to foster an environment here where people
>>> will feel welcome.
>> 
>> Your words remind me of this:
>> 
>> "The seriousness of the charge mandates that we investigate
>> this. Even though there is no evidence, the seriousness of
>> the charge is what matters."
>>   --Tom Foley (D) Speaker of the House
> 
> Amusing, like Bill Clinton's "depends what your definition
> of is is", or Donald Rumsfeld's known unknowns and unknown 
> unknowns.  But yet, isn't investigation what produces evidence?
> Sometimes things that sound silly at first really aren't.

Yes, investigation is what produces evidence but "probable
cause" is needed to begin the investigation.  That means
there has to be something more than just an accusation.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bigotry and hate speech on the python mailing list

2017-04-18 Thread Wildman via Python-list
On Tue, 18 Apr 2017 15:54:17 +1000, Ben Finney wrote:

> Wildman via Python-list <python-list@python.org> writes:
> 
>> "The seriousness of the charge mandates that we investigate
>> this. Even though there is no evidence, the seriousness of
>> the charge is what matters."
>>   --Tom Foley (D) Speaker of the House
> 
> That sounds right to me, provided one reads “there is no evidence” as a
> statement about what evidence is present before anyone goes looking for
> it (“there is no evidence we are yet aware of”).
> 
> In other words: before any evidence exists and before the investigation
> is made, it's a mistake to reach any conclusion about the truth of the
> charge.

Spoken like a true progressive.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bigotry and hate speech on the python mailing list

2017-04-17 Thread Wildman via Python-list
On Tue, 18 Apr 2017 08:23:34 +1000, Ben Finney wrote:

> Paul Rubin  writes:
> 
>> Rurpy  writes:
>> > A couple weeks ago a frequent poster here (Steve D'Aprano
>> > ) called another participant an "ugly
>> > american"
>>
>> Oh stop trolling.
> 
> Paul, that is uncalled for. The charge of bigotry is not to be lightly
> dismissed, and we do want to foster an environment here where people
> will feel welcome.

Your words remind me of this:

"The seriousness of the charge mandates that we investigate
this. Even though there is no evidence, the seriousness of
the charge is what matters."
  --Tom Foley (D) Speaker of the House


-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With pkexec

2017-04-05 Thread Wildman via Python-list
On Mon, 03 Apr 2017 14:29:56 -0500, Wildman wrote:

> Python 3.4.2
> Tkinter 8.6
> GCC 4.9.1 on Linux
> 
> I am working on a gui program using Tkinter. The program will
> have a feature to restart as root.  I am testing different gui
> front-ends from a terminal to raise privileges and I want to
> be able to use as many as possible for obvious reasons.  Gksu,
> kdesudo and su-to-root all work perfectly.  However, I have a
> problem with pkexec.  Here is the command I am using from a
> terminal:
> 
> $ pkexec python3 /home/user/Python/linfo-tk/linfo-tk.py
> 
> I get this error:
> 
> Traceback (most recent call last):
>   File "/home/user/Python/linfo-tk/linfo-tk.py", line 455, in 
> root = tk.Tk()
>   File "/usr/lib/python3.4/tkinter/__init__.py", line 1854, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive, 
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable

I am posting this follow-up for any Linux developer that might
be working on a gui program that requires root permissions.
My research revealed that programs like gksu are not going to
be supported long term.  Some distros have already dropped
gksu in favor of pkexec.

Pkexec is part of the PolicyKit package, policykit-1.  By
default it will not work with gui (X11) programs but that
behavior can be changed by using a .policy file placed in
/usr/share/polkit-1/actions/.  Once I created such a file,
pkexec worked perfectly with my program.  So my problem
was not Python related.

Below is the actual .policy file I am using.  It could be
edited to work with any program.  Lots of info on the
web about pkexec and the HTML .policy file.  Just search
on something like "run program with pkexec".  The name
of the file is com.ubuntu.pkexec.linfo-tk.policy.  Here
is the contents:



http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd;>



  Wildman Productions
  
Authentication is required to run Linfo-tk as root

  auth_admin
  auth_admin
  auth_admin

/opt/linfo-tk/linfo-tk.py
TRUE
  




-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Request Help With pkexec

2017-04-03 Thread Wildman via Python-list
Python 3.4.2
Tkinter 8.6
GCC 4.9.1 on Linux

I am working on a gui program using Tkinter. The program will
have a feature to restart as root.  I am testing different gui
front-ends from a terminal to raise privileges and I want to
be able to use as many as possible for obvious reasons.  Gksu,
kdesudo and su-to-root all work perfectly.  However, I have a
problem with pkexec.  Here is the command I am using from a
terminal:

$ pkexec python3 /home/user/Python/linfo-tk/linfo-tk.py

I get this error:

Traceback (most recent call last):
  File "/home/user/Python/linfo-tk/linfo-tk.py", line 455, in 
root = tk.Tk()
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1854, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, 
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

The display environment variable is set:

$ echo $DISPLAY
:0.0

And the program displays and works perfectly in every other way.
I would appreciate any insight.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Who are the "spacists"?

2017-03-26 Thread Wildman via Python-list
On Sun, 26 Mar 2017 15:18:06 +0200, Mikhail V wrote:

> On 26 March 2017 at 06:16, Wildman via Python-list
> <python-list@python.org> wrote:
>> On Tue, 21 Mar 2017 15:15:14 +0100, Mikhail V wrote:
>>
>>> And on linux console, by default one does not even have good
>>> possibilities for text-mode pseudographics, it was more relevant
>>> in DOS where one had rich possibilities and programmable
>>> binary fonts.
>>>
>>> Mikhail
>>
>> Nonsense.
> 
> Why? IIRC I can do good pseudographics on linux only with extended
> unicode character sets, so yes it is possible, is that what you mean?

No.  The same ASCII character set that was available in DOS is
available in Linux without unicode.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Who are the "spacists"?

2017-03-25 Thread Wildman via Python-list
On Tue, 21 Mar 2017 15:15:14 +0100, Mikhail V wrote:

> And on linux console, by default one does not even have good
> possibilities for text-mode pseudographics, it was more relevant
> in DOS where one had rich possibilities and programmable
> binary fonts.
> 
> Mikhail

Nonsense.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Who are the "spacists"?

2017-03-21 Thread Wildman via Python-list
On Tue, 21 Mar 2017 06:01:26 +1100, Chris Angelico wrote:

> On Tue, Mar 21, 2017 at 4:39 AM, Steve D'Aprano
>  wrote:
>> And yet I'm forever being told by my Linux sys admin work mates "don't use
>> tabs, because they break everything". For another example, see JMZ's essay
>> (its already been linked to twice in this thread, look it up).
>>
>> We've had a similar attitude right here from Marko, who insists that
>> anything except 8-column tabs is the Devil's Work. (Or something like
>> that -- to be perfectly honest, I'm not really sure I understand *what*
>> Marko's objection is.)
>>
>> So okay, if tabs work fine with Unix tools, why do so many Unix people avoid
>> tabs as if they were radioactive plague?
> 
> Can you ask your workmates to elaborate? I'd love to hear.
> 
> ChrisA

I would love to hear also.  I've been using Linux for about
10 years and I have never had anything "break" because of a
tab.  Sounds like a case of Chicken Little to me.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Wildman via Python-list
On Fri, 10 Mar 2017 18:51:35 +, Chris Green wrote:

> I'm using the excellent tutorial at 
> https://python-gtk-3-tutorial.readthedocs.io
> and occasionally want reference documentation, is there reference
> documentation for this on line?

https://developer.gnome.org/gtk3/

-- 
 GNU/Linux user #557453
Hey Mr. Ed, why the long face?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem With Tkinter Font

2017-02-26 Thread Wildman via Python-list
On Sun, 26 Feb 2017 09:17:00 +0100, Peter Otten wrote:

> Wildman via Python-list wrote:
> 
>> Python 3.4.2
>> Tkinter 8.6
>> Linux
>> 
>> I want to set the font in a GUI program I am working on.
>> Here is the pertinent code I am using...
>> 
>> from tkinter import font
>> 
>> myfont = font.Font(family='Helvetica', size=10, weight='bold')
>> 
>> Here is the error I get...
>> 
>> Traceback (most recent call last):
>>   File "./test.py", line 41, in 
>> myfont = font.Font(family='Helvetica', size=10, weight="bold")
>>   File "/usr/lib/python3.4/tkinter/font.py", line 93, in __init__
>> tk.call("font", "create", self.name, *font)
>> AttributeError: 'NoneType' object has no attribute 'call'
>> 
>> From my research, the syntax is correct but I am having
>> doubts.  Can anyone clarify?
> 
> If you do not provide the root argument there is still an implicit 
> dependency:
> 
> """
> class Font:
> ...
> def __init__(self, root=None, font=None, name=None, exists=False,
>  **options):
> if not root:
> root = tkinter._default_root
> tk = getattr(root, 'tk', root)
> 
> """
> 
>>>> import tkinter
>>>> from tkinter import font
>>>> font.Font(family="Helpvetica", size=10, weight="bold")
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python3.4/tkinter/font.py", line 93, in __init__
> tk.call("font", "create", self.name, *font)
> AttributeError: 'NoneType' object has no attribute 'call'
>>>> root = tkinter.Tk()
>>>> font.Font(family="Helpvetica", size=10, weight="bold")
> 
> 
> So you have to create the main window before you can create a Font.

OK, that makes sense.  I knew I was doing something dumb
or in this case, not doing it.  Thank you.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem With Tkinter Font

2017-02-25 Thread Wildman via Python-list
Python 3.4.2
Tkinter 8.6
Linux

I want to set the font in a GUI program I am working on.
Here is the pertinent code I am using...

from tkinter import font

myfont = font.Font(family='Helvetica', size=10, weight='bold')

Here is the error I get...

Traceback (most recent call last):
  File "./test.py", line 41, in 
myfont = font.Font(family='Helvetica', size=10, weight="bold")
  File "/usr/lib/python3.4/tkinter/font.py", line 93, in __init__
tk.call("font", "create", self.name, *font)
AttributeError: 'NoneType' object has no attribute 'call'

>From my research, the syntax is correct but I am having
doubts.  Can anyone clarify?

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With ttk.Notebook Tabs

2017-02-21 Thread Wildman via Python-list
On Tue, 21 Feb 2017 18:22:31 +, MRAB wrote:

> On 2017-02-21 18:02, Wildman via Python-list wrote:
>> Python 3.4.2
>> Linux platform
>>
>>
>> I am working on a program that has tabs created with ttk.Notebook.
>> The code for creating the tabs is working but there is one thing I
>> have not been able to figure out.  As is, the tabs are located up
>> against the lower edge of the caption bar.  I would like to have
>> them a little lower to make room above the tabs for other widgets
>> such as labels and/or command buttons.  Here is the code I use to
>> create the window and tabs...
>>
>> class Window(tk.Frame):
>> def __init__(self, master=None):
>> tk.Frame.__init__(self, master)
>> master.title("My Program")
>> nb = ttk.Notebook(root, width=600, height=340)
>> tab1 = tk.Frame(nb)
>> tab2 = tk.Frame(nb)
>> nb.add(tab1, text="Tab1")
>> nb.add(tab2, text="Tab2")
>> nb.pack(expand=1, fill="both")
>>
>> I have tried the grid and place methods to move the tabs down but
>> neither works.  I have tried the methods both before and after the
>> pack method.  Here is an example of what I have tried...
>>
>> nb.grid(row=2, column=2)
>> or
>> nb.place(x=10, y=10)
>>
>> Would be appreciated if anyone could provide any guidance.
>>
> If you want other widgets above the Notebook widget, why don't you just 
> put them there in a frame?

Thanks for the reply.  That approach would work but I found
a simple method that serves the purpose using padx/pady.  I
was doing my research in the areas of grid and place.  Didn't
think about pack.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With ttk.Notebook Tabs

2017-02-21 Thread Wildman via Python-list
On Tue, 21 Feb 2017 12:02:50 -0600, Wildman wrote:

> Python 3.4.2
> Linux platform
> 
> 
> I am working on a program that has tabs created with ttk.Notebook.
> The code for creating the tabs is working but there is one thing I
> have not been able to figure out.  As is, the tabs are located up
> against the lower edge of the caption bar.  I would like to have
> them a little lower to make room above the tabs for other widgets
> such as labels and/or command buttons.  Here is the code I use to
> create the window and tabs...
> 
> class Window(tk.Frame):
> def __init__(self, master=None):
> tk.Frame.__init__(self, master)
> master.title("My Program")
> nb = ttk.Notebook(root, width=600, height=340)
> tab1 = tk.Frame(nb)
> tab2 = tk.Frame(nb)
> nb.add(tab1, text="Tab1")
> nb.add(tab2, text="Tab2")
> nb.pack(expand=1, fill="both")
> 
> I have tried the grid and place methods to move the tabs down but
> neither works.  I have tried the methods both before and after the
> pack method.  Here is an example of what I have tried...
> 
> nb.grid(row=2, column=2)
> or
> nb.place(x=10, y=10)
> 
> Would be appreciated if anyone could provide any guidance.

I posted too quickly.  I found my answer...

nb.pack(expand=1, fill="both", padx=20, pady=20)

Sorry.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Request Help With ttk.Notebook Tabs

2017-02-21 Thread Wildman via Python-list
Python 3.4.2
Linux platform


I am working on a program that has tabs created with ttk.Notebook.
The code for creating the tabs is working but there is one thing I
have not been able to figure out.  As is, the tabs are located up
against the lower edge of the caption bar.  I would like to have
them a little lower to make room above the tabs for other widgets
such as labels and/or command buttons.  Here is the code I use to
create the window and tabs...

class Window(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
master.title("My Program")
nb = ttk.Notebook(root, width=600, height=340)
tab1 = tk.Frame(nb)
tab2 = tk.Frame(nb)
nb.add(tab1, text="Tab1")
nb.add(tab2, text="Tab2")
nb.pack(expand=1, fill="both")

I have tried the grid and place methods to move the tabs down but
neither works.  I have tried the methods both before and after the
pack method.  Here is an example of what I have tried...

nb.grid(row=2, column=2)
or
nb.place(x=10, y=10)

Would be appreciated if anyone could provide any guidance.

-- 
 GNU/Linux user #557453
Keyboard not detected! Press any key to continue...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: print odd numbers of lines from tekst WITHOUT space between lines

2017-02-18 Thread Wildman via Python-list
On Sat, 18 Feb 2017 09:38:32 -0800, TTaglo wrote:

> i = 1
> f = open ('rosalind_ini5(1).txt')
> for line in f.readlines():
> if i % 2 == 0:
> print line
> i += 1
> 
> 
> How do i get output without breaks between the lines?
> 
> Result:
> 
> Other things just make you swear and curse
> 
> When you're chewing on life's gristle, don't grumble give a whistle
> 
> This will help things turn out for the best
> 
> Always look on the bright side of life

In Python 3 you can do this:

print(line, end="")

For Python 2 use this:

import sys
  .
  .
  .
sys.stdout.write(line)

Don' forget...
f.close()

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problems with scripts

2017-02-13 Thread Wildman via Python-list
On Mon, 13 Feb 2017 10:08:11 -0800, Lauren Fugate wrote:

> So I tried both of these and they didn't change anything, the python shell 
> printed the same things...

The first assignment is overly complicated.  The extra input functions are
useless.  There is no loopback to check the input.  Also, input returns
a string not an int or float.  Try this:

x = ["17","18","19","20"]
answer = None
print("How old are you: 17, 18, 19, or 20?")
while answer not in x:
answer = input("> ")
if answer in x:
print("Wow, you are old!")
else:
print("You just can't follow drections, can you? Choose either 17, 18, 
19, or 20.")

Keep in mind that the above code does not give you a way out.
One of the expected numbers must be entered.

I'll leave the second one for you to figure out.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problems with scripts

2017-02-13 Thread Wildman via Python-list
On Mon, 13 Feb 2017 08:30:32 -0800, lauren.sophia1998 wrote:

> Hello! I have 2 python assignments that I just can't figure out. The first 
> one returns the same thing no matter what I input and the second won't accept 
> "done" to stop the program and return answers. Please help! 
> 
> 1)
> print("How old are you: 17, 18, 19, or 20?")
> answer = input("> ")
> if answer == 17 or 18 or 19 or 20:
> print("Wow, you are old!")
> elif answer != 17 or 18 or 19 or 20:
> if type(answer) is int or float:
> print("You just can't follow drections, can you? Choose either 17, 
> 18, 19, or 20.")
> input("> ")
> elif type(answer) is str:
> print("That isn't even a number. Choose either 17, 18, 19, or 20.")
> input("> ")

Incorrect use of 'or'.

if answer == 17 or answer == 18 or answer == 19 or answer == 20:

elif answer != 17 and answer != 18 and answer != 19 and answer != 20:

if type(answer) is int or type(answer) is float:

> 2)
> print("This program keeps track of the prices of items and how many items 
> bought at that price. Enter 'done' to return the answers.")
> item_num = 1
> total_price = 0
> price = input("What is the price of item number " + str(item_num) + " ? ")
> total_items = 0
> how_many = input("How many items at that price? ")
> while price or how_many != "done":
> total_price = int(total_price) + int(price)
> total_items = int(total_items) + int(how_many)
> item_num = item_num + 1
> price = input("What is the price of item number " + str(item_num) + " ? ")
> how_many = input("How many items at that price? ")
> 
> if input == done:
> print("The total price is $" + str(total_price) + ". And the number of 
> items for that price is " + str(total_items) + ".")

Same here:

while price != "done" and how_many != "done":

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess problem

2017-02-09 Thread Wildman via Python-list
On Fri, 10 Feb 2017 09:53:32 +1100, Cameron Simpson wrote:

> On 09Feb2017 11:59, Wildman  wrote:
>>Here is a method I frequently use to replace the which
>>command. (air code)
>>
>>import os
>>pathlist = os.environ["PATH"].split(":")
>>
>>def which(target)
>>for p in pathlist:
>>fullpath = p + "/" + target
>>if os.path.isfile(fullpath):
>>return fullpath, True
>>return "", False
> 
> Cleaner is to return the path if found, or None if not.

I don't see this as an important issue but you are
right.

>>target, found = which("pandoc")
>>if found:
>>target will contain the full path to pandoc
>>else:
>>pandoc was not found
> 
> You want to check for execute permssion too.

For my uses of the above code, it is unlikely that
the 'target' would not have the exec bit set.  But,
your suggestion is valid due to the fact that I
should not take anything for granted.

> Cheers,
> Cameron Simpson 

Corrected code:

def which(target)
for p in pathlist:
fullpath = p + "/" + target
if os.path.isfile(fullpath) and os.access(fullpath, os.X_OK):
return fullpath, True
return None, False

Thanks.

-- 
 GNU/Linux user #557453
Keyboard not detected! Press any key to continue...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess problem

2017-02-09 Thread Wildman via Python-list
On Thu, 09 Feb 2017 11:16:18 -0600, Andreas Paeffgen wrote:

> I guess which does not return an error code. If it does not find 
> anything, the return is just blank. If it finds something, the path is 
> returned.
> 
> So the change of code did not help, because there is just no error message.
> Could there be a $path problem in the subprocess started inside the binary?

Here is a method I frequently use to replace the which
command. (air code)

import os
pathlist = os.environ["PATH"].split(":")

def which(target)
for p in pathlist:
fullpath = p + "/" + target
if os.path.isfile(fullpath):
return fullpath, True
return "", False

target, found = which("pandoc")
if found:
target will contain the full path to pandoc
else:
pandoc was not found

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-05 Thread Wildman via Python-list
On Mon, 06 Feb 2017 09:07:34 +1100, Steve D'Aprano wrote:

> On Sun, 5 Feb 2017 07:01 pm, Wildman wrote:
> 
>> Sure, you
>> could trick someone into running a program that could
>> mess with $HOME but that is all.  For anyone, like me,
>> that makes regular backups, that is not a big problem.
>> To do any real damage to the system or install a key
>> logger or some other malicious software, root access
>> would be required.
> 
> The complacency of Linux users (and I include myself here) is frightening.

No comment. :-)

> Why do you value the OS more than your own personal files? In the worst
> case, you could re-install the OS is a couple of hours effort. Losing your
> personal files, your home directory and email, could be irreplaceable.

I wold not say I value the OS more.  It is that anything I
have that I consider important does not stay in $HOME very
long without being backed up or moved to an external drive.

> You're also ignoring the possibility of privilege-escalation attacks.

The odds of that happening is very low.  You should know that.
There are very few actual exploits in the wild.  Whenever one
is discovered, it is fixed quickly.  You would be hard pressed
to find more than a few examples of where a vulnerability was
actually exploited.

> As far as "regular backups", well, you're just not thinking deviously
> enough. If I were to write a ransomware application, running as the regular
> user, I would have the application encrypt files and emails just a few at a
> time, over a period of many weeks, gradually increasing the rate. By the
> time the victim has realised that their files have been encrypted, their
> backups have been compromised too: you can restore from backup, but you'll
> be restoring the encrypted version.
> 
> Obviously this requires tuning. How many files will people be willing to
> just write-off as lost rather than pay the ransom? How quickly do you
> accelerate the process of encrypting files to maximize the number of people
> who will pay?

I should explain a few things that will make my position
clearer.  First of all, I am not advocating for anyone to
change their computing practices.  If you are comfortable
with your methods, who am I to tell you different?

I am an amateur programmer and therefore I do not make a
living writing code.  If I suddenly lost all my code, it
would not be the end of the world for me.  I would have
enjoyment writing it again.  Because of this I am not
very paranoid when it come to my computer data, although
I do practice safe surfing when it comes to the internet.
Scripting and Java stays off unless it is needed by a
'known' site.  Also, I never click unknown links without
doing a little sniffing first.

And last I would like to say that I admit some of the
scenarios you and others have laid out could happen,
but, in my circumstance, it is very unlikely.  One
would have a hard time placing a program on my computer
and running it without me knowing about it.  No, that
is not a challenge. :-)

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-05 Thread Wildman via Python-list
On Sat, 04 Feb 2017 19:12:55 +, Grant Edwards wrote:

> On 2017-02-04, Wildman via Python-list <python-list@python.org> wrote:
>>> 
>>> The next time you are in the /tmp directory looking for something, can
>>> you guess what happens when you mistype "ls" as "sl"?
>>> 
>>>> DOS and Windows has searched the current directory since their
>>>> beginning.  Is that also dangerous?
>>> 
>>> Yes.
>>
>> Your scenario assumes the malicious user has root access
>> to be able to place a file into /tmp.
> 
> Nope.  /tmp is world-writable.

Yea, I realized that right after I clicked post.  I was
thinking of the fact that /tmp is owned by root.
 
>> And there would have to be some reason why I would be looking around
>> in /tmp.  After 10 years of using Linux, it hasn't happened yet.
>> And last I would have to be a complete idiot.
> 
> To have put '.' in your path?

That is something I would never do.  Not because I think
it is dangerous but because it had never occurred to me.
Anything that I run in the current directory, I always
prefix it with './' out of habit.  Never thought of doing
anything else.

> Or to have typed 'sl' by mistake?

Well, maybe not an idiot but something would have to be
going on to misspell a two letter command. 

>> I suppose all that could be a reality, but, how many computers do
>> you know of have been compromised in this manor?
> 
> I've known a few people over the years who've been caught by that
> trick.  The "evil" program was always more of a joke and did no real
> harm.

I don't consider that being compromised.  Sure, you
could trick someone into running a program that could
mess with $HOME but that is all.  For anyone, like me,
that makes regular backups, that is not a big problem.
To do any real damage to the system or install a key
logger or some other malicious software, root access
would be required.  As a Linux user you already know
that.  That is the scenario where idiot would be the
correct term.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-04 Thread Wildman via Python-list
On Sat, 04 Feb 2017 18:25:03 +, Grant Edwards wrote:

> On 2017-02-04, Wildman via Python-list <python-list@python.org> wrote:
> 
>> No, I do not know.  You might try your question in a linux specific
>> group.  Personally I don't understand the danger in having the dot
>> in the path.  The './' only means the current directory.
> 
> It allows a malicous user to put an evil executable someplace public
> like /tmp and have it executed accidentally.  For example, let's say
> this executable file was named "sl" and placed in /tmp.
> 
> --sl--
> #!/bin/bash
> rm -rf $HOME
> --
> 
> The next time you are in the /tmp directory looking for something, can
> you guess what happens when you mistype "ls" as "sl"?
> 
>> DOS and Windows has searched the current directory since their
>> beginning.  Is that also dangerous?
> 
> Yes.

Your scenario assumes the malicious user has root access
to be able to place a file into /tmp.  And there would
have to be some reason why I would be looking around in
/tmp.  After 10 years of using Linux, it hasn't happened
yet.  And last I would have to be a complete idiot.

I suppose all that could be a reality, but, how many
computers do you know of have been compromised in this
manor?

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-04 Thread Wildman via Python-list
On Sat, 04 Feb 2017 11:27:01 +0200, Jussi Piitulainen wrote:

> Wildman writes:
> 
> [snip]
> 
>> If anyone is interested the correct way is to add this to
>> /etc/profile (at the bottom):
>>
>> PATH=$PATH:./
>> export PATH
> 
> Out of interest, can you think of a corresponding way that a mere user
> can remove the dot from their $PATH after some presumably well-meaning
> system administrator has put it there?
> 
> Is there any simple shell command for it? One that works whether the dot
> is at the start, in the middle, or at the end, and with or without the
> slash, and whether it's there more than once or not at all.
> 
> And I'd like it to be as short and simple as PATH="$PATH:.", please.

No, I do not know.  You might try your question in
a linux specific group.  Personally I don't understand
the danger in having the dot in the path.  The './'
only means the current directory.  DOS and Windows
has searched the current directory since their
beginning.  Is that also dangerous?

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-03 Thread Wildman via Python-list
On Sat, 04 Feb 2017 09:25:42 +1100, Cameron Simpson wrote:

> On 03Feb2017 14:55, Wildman <best_...@yahoo.com> wrote:
>>On Fri, 03 Feb 2017 13:19:30 -0700, Michael Torrie wrote:
>>
>>> On 02/03/2017 12:07 PM, Wildman via Python-list wrote:
>>>> Sorry, I forgot something important.  If you use
>>>> /etc/rc.local, the execute bit must be set.
>>>
>>> I don't think this is what Neal Becker was asking about.  He's talking
>>> about the Python module search path (sys.path) not the operating system
>>> PATH variable.  Correct me if I'm wrong.
>>
>>After re-reading the post I see you are correct.
>>I will endeavor to read a little closer and a
>>little slower in the future.
> 
> Also, what you describe with rc.local wouldn't work anyway, even if it had 
> ben 
> what was asked.
> 
> Cheers,
> Cameron Simpson <c...@zip.com.au>

Of course, you are correct.  I don't know where my head
was.  I think my tongue got in front of my eye teeth and
I could not see what I was saying.  :-)

If anyone is interested the correct way is to add this to
/etc/profile (at the bottom):

PATH=$PATH:./
export PATH

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-03 Thread Wildman via Python-list
On Fri, 03 Feb 2017 13:19:30 -0700, Michael Torrie wrote:

> On 02/03/2017 12:07 PM, Wildman via Python-list wrote:
>> Sorry, I forgot something important.  If you use
>> /etc/rc.local, the execute bit must be set.
> 
> I don't think this is what Neal Becker was asking about.  He's talking
> about the Python module search path (sys.path) not the operating system
> PATH variable.  Correct me if I'm wrong.

After re-reading the post I see you are correct.
I will endeavor to read a little closer and a
little slower in the future.

-- 
 GNU/Linux user #557453
"Well, that's quite different. Never mind."
  -Emily Litella
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-03 Thread Wildman via Python-list
On Fri, 03 Feb 2017 12:58:15 -0600, Wildman wrote:

> On Fri, 03 Feb 2017 11:06:00 -0500, Neal Becker wrote:
> 
>> I want to make sure any modules I build in the current directory overide any 
>> others.  To do this, I'd like sys.path to always have './' at the beginning.
>> 
>> What's the best way to ensure this is always true whenever I run python3?
> 
> In python, this method will work but it is only in effect
> for the running process that calls it while it is running.
> It is not system wide and it is not permanent.
> 
> import os
> os.environ["PATH"] = os.environ["PATH"] + ":./"
>   or
> os.environ["PATH"] = "./:" + os.environ["PATH"]
> 
> (assuming Linux platform)
> To make it permanent for a certain user, add one of
> these lines to /home/user/.profile and log out/in:
> 
> PATH="$PATH:./"
>   or
> PATH="./:$PATH"
> 
> To make it permanent for all users, add one of
> these pairs of lines to /etc/rc.local and reboot:
> 
> export PATH=$PATH:./
> exit 0
>   or
> export PATH=./:$PATH
> exit 0
> 
> Add 'exit 0' only if it doesn't exist already and it
> must be the last line.  If /etc/rc.local does not
> exist, create it.

Sorry, I forgot something important.  If you use
/etc/rc.local, the execute bit must be set.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-03 Thread Wildman via Python-list
On Fri, 03 Feb 2017 11:06:00 -0500, Neal Becker wrote:

> I want to make sure any modules I build in the current directory overide any 
> others.  To do this, I'd like sys.path to always have './' at the beginning.
> 
> What's the best way to ensure this is always true whenever I run python3?

In python, this method will work but it is only in effect
for the running process that calls it while it is running.
It is not system wide and it is not permanent.

import os
os.environ["PATH"] = os.environ["PATH"] + ":./"
  or
os.environ["PATH"] = "./:" + os.environ["PATH"]

(assuming Linux platform)
To make it permanent for a certain user, add one of
these lines to /home/user/.profile and log out/in:

PATH="$PATH:./"
  or
PATH="./:$PATH"

To make it permanent for all users, add one of
these pairs of lines to /etc/rc.local and reboot:

export PATH=$PATH:./
exit 0
  or
export PATH=./:$PATH
exit 0

Add 'exit 0' only if it doesn't exist already and it
must be the last line.  If /etc/rc.local does not
exist, create it.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to know what to install (Ubuntu/Debian) for a given import?

2017-02-01 Thread Wildman via Python-list
On Wed, 01 Feb 2017 21:29:00 +, Chris Green wrote:

> Wildman  wrote:
>> On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote:
>> 
>> > Wildman  wrote:
>> >> On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
>> >> 
>> >> > I'm often hitting this problem, how does one find out what package to
>> >> > install to provide what a give import needs?
>> >> > 
>> >> > Currently I'm modifying some code which has 'import gtk', I want to
>> >> > migrate from Python 2 to Python 3 if I can but at the moment the
>> >> > import fails in Python 3.
>> >> > 
>> >> > There are dozens of packages in the Ubuntu repositories which *might*
>> >> > provide what I need I don't want to try them all!  So, is there an
>> >> > easy way to find out?
>> >> > 
>> >> > ... and while I'm here, can someone tell me what package I need?
>> >> 
>> >> Try this:
>> >> 
>> >> import gi
>> >> gi.require_version('Gtk', '3.0')
>> >> from gi.repository import Gtk
>> >> 
>> > That works but it's a workaround rather than the proper way to do it
>> > isn't it?
>> 
>> It is the proper way.  This page helps explain it.
>> 
>> http://askubuntu.com/questions/784068/what-is-gi-repository-in-python
>> 
> OK, thank you, what a strange way to do it.

I am sure there is a reason and I believe it has
something to do with the fact that GTK3 is a recent
addition.  Things might change in the future.

>> > ... and doesn't it need an internet connection?
>> 
>> No.
>> 
> OK, no problem, but isn't it very non-portable?

I don't see why not.  It should work on any system
that has Python3 installed, at least that is my
understanding.  I'm sure someone will correct me
if I'm wrong.

OTOH if you want in insure 100% portability with any
script, you can use pyinstaller.

To install for Python2:
  pip install pyinstaller

For Python3:

  pip3 install pyinstaller

http://www.pyinstaller.org/

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to know what to install (Ubuntu/Debian) for a given import?

2017-02-01 Thread Wildman via Python-list
On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote:

> Wildman  wrote:
>> On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:
>> 
>> > I'm often hitting this problem, how does one find out what package to
>> > install to provide what a give import needs?
>> > 
>> > Currently I'm modifying some code which has 'import gtk', I want to
>> > migrate from Python 2 to Python 3 if I can but at the moment the
>> > import fails in Python 3.
>> > 
>> > There are dozens of packages in the Ubuntu repositories which *might*
>> > provide what I need I don't want to try them all!  So, is there an
>> > easy way to find out?
>> > 
>> > ... and while I'm here, can someone tell me what package I need?
>> 
>> Try this:
>> 
>> import gi
>> gi.require_version('Gtk', '3.0')
>> from gi.repository import Gtk
>> 
> That works but it's a workaround rather than the proper way to do it
> isn't it?

It is the proper way.  This page helps explain it.

http://askubuntu.com/questions/784068/what-is-gi-repository-in-python

> ... and doesn't it need an internet connection?

No.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to know what to install (Ubuntu/Debian) for a given import?

2017-02-01 Thread Wildman via Python-list
On Wed, 01 Feb 2017 17:12:26 +, Chris Green wrote:

> I'm often hitting this problem, how does one find out what package to
> install to provide what a give import needs?
> 
> Currently I'm modifying some code which has 'import gtk', I want to
> migrate from Python 2 to Python 3 if I can but at the moment the
> import fails in Python 3.
> 
> There are dozens of packages in the Ubuntu repositories which *might*
> provide what I need I don't want to try them all!  So, is there an
> easy way to find out?
> 
> ... and while I'm here, can someone tell me what package I need?

Try this:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is shutil.get_terminal_size useless?

2017-01-29 Thread Wildman via Python-list
On Sat, 28 Jan 2017 19:03:42 +1100, Steve D'Aprano wrote:

> shutil.get_terminal_size returns the wrong values when you pipe your output
> to another process, even it you do so in a terminal. Consider this script:
> 
> 
> import os
> import shutil
> print('shutil:', shutil.get_terminal_size(fallback=(999, 999)))
> print('os:', os.get_terminal_size(0))
> 
> 
> That uses two different methods to get the terminal size. If I run that in a
> terminal in the normal way, it works fine, returning the correct size for
> my terminal:
> 
> 
> [steve@ando ~]$ python3.5 test_gts.py
> shutil: os.terminal_size(columns=116, lines=29)
> os: os.terminal_size(columns=116, lines=29)
> 
> 
> But if I pipe the output to something else, the shutil version fails to
> determine the correct terminal size, and falls back on the default:
> 
> 
> [steve@ando ~]$ python3.5 test_gts.py | cat
> shutil: os.terminal_size(columns=999, lines=999)
> os: os.terminal_size(columns=116, lines=29)
> 
> 
> while the os version gives the correct result.
> 
> Is shutil.get_terminal_size useless? When, if ever, should I use it in
> preference to the os version? If the shutil version is broken, can it be
> fixed?
> 
> 
> Thanks to Bernardas Ališauskas:
> 
> http://granitosaurus.rocks/getting-terminal-size.html

I can suggest a third approach to try but I have not tried
piping it.  YMMV.

import fcntl
import os
import struct
import termios

tty = os.open(os.ctermid(), os.O_RDONLY)
ts = struct.unpack("hh", fcntl.ioctl(tty, termios.TIOCGWINSZ, "1234"))
os.close(tty)
columns = ts[1]
rows = ts[0]
print(str(columns) + "x" + str(rows))

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How coding in Python is bad for you

2017-01-23 Thread Wildman via Python-list
On Mon, 23 Jan 2017 20:39:26 +, Jon Ribbens wrote:

> On 2017-01-23, alister  wrote:
>> On Tue, 24 Jan 2017 07:19:42 +1100, Chris Angelico wrote:
>>> I believe that's "bad for you" in the sense that chocolate is bad for
>>> you.
>>> 
>>> It isn't.
>>
>> chocolate is a poison (lethal dose for a human approx 22lb)
> 
> That's a meaningless statement. *Everything* is a poison
> in sufficient quantities.

Yes, even water.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2017-01-03 Thread Wildman via Python-list
On Mon, 02 Jan 2017 20:25:25 -0800, Ethan Furman wrote:

> On 01/02/2017 09:53 AM, Wildman via Python-list wrote:
> 
> [rude ascii art omitted]
> 
> That is a completely inappropriate response.

Yes it was.  I tend to get upset when told to shut up and
go away for no good reason.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2017-01-02 Thread Wildman via Python-list
On Sun, 01 Jan 2017 23:02:34 -0800, einstein1410 wrote:

> I really don't care the person like you.
> Leave my posts, if don't like it.
> Why wasting your as well as my time.
> Just get lost man, or shut up.
 _ _
|_|   |_|
| | /^^^\ | |
   _| |_  (| "o" |)  _| |_
 _| | | | _(_---_)_ | | | |_
| | | | |' |_| |_| `| | | | |
|  |   / \   |  |
 \/  / /(. .)\ \  \/
   \/  / /  | . |  \ \  \/
 \  \/ /||Y||\ \/  /
  \__/  || ||  \__/
() ()
|| ||
   ooO Ooo
-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2017-01-01 Thread Wildman via Python-list
On Sun, 01 Jan 2017 10:41:22 -0800, einstein1410 wrote:

> What contribution I had made especially valuable?

Ask your mommy what sarcasm means.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2016-12-30 Thread Wildman via Python-list
On Fri, 30 Dec 2016 19:23:17 -0700, Michael Torrie wrote:

> On 12/30/2016 07:05 PM, Wildman via Python-list wrote:
>> On Fri, 30 Dec 2016 23:39:43 +, Erik wrote:
>> 
>>> On 30/12/16 23:34, einstein1...@gmail.com wrote:
>>>> You are also confusing me.
>>>> But there mustbe  some reason.
>>>> What happens if your student questions you like this.?
>>>> And may be those who questions like this will surely be the developer of 
>>>> its successor language.
>>>> Because out of thousands, only one may asks this, whom you all will 
>>>> consider fool, but he's the only genius
>>>
>>> Do not feed the troll.
>>>
>>> E.
>> 
>> Please explain how what I said is trolling.  Perhaps it was a little
>> snide but I tend to get that way when trying to explain the obvious.
> 
> Hmm. I thought he was referring to einstein1410...  It was his message
> he was replying to, not yours, and I took it as a request to the rest of
> us (sorry, Erik--couldn't resist posting).

I took it to mean that he was telling einstein1410 to not feed
the trolls.  If I am wrong then my apologies to Erik.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2016-12-30 Thread Wildman via Python-list
On Fri, 30 Dec 2016 23:39:43 +, Erik wrote:

> On 30/12/16 23:34, einstein1...@gmail.com wrote:
>> You are also confusing me.
>> But there mustbe  some reason.
>> What happens if your student questions you like this.?
>> And may be those who questions like this will surely be the developer of its 
>> successor language.
>> Because out of thousands, only one may asks this, whom you all will consider 
>> fool, but he's the only genius
> 
> Do not feed the troll.
> 
> E.

Please explain how what I said is trolling.  Perhaps it was a little
snide but I tend to get that way when trying to explain the obvious.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2016-12-30 Thread Wildman via Python-list
On Fri, 30 Dec 2016 15:34:16 -0800, einstein1410 wrote:

> You are also confusing me.
> But there mustbe  some reason.
> What happens if your student questions you like this.?

I am not a teacher.

> And may be those who questions like this will surely be the developer of its 
> successor language.
> Because out of thousands, only one may asks this, whom you all will consider 
> fool, but he's the only genius.

To get an answer to your questions you need to ask the developer.  I don't
think I can get any clearer.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning and experimenting python.

2016-12-30 Thread Wildman via Python-list
On Fri, 30 Dec 2016 11:08:30 -0800, einstein1410 wrote:

> LAN you are right. I am agree with you that it's easy to recognise.
> 
> But look
> $ for normal user
> # for special user/root
> % for other shell
 For python 
> And so on...
> Why?
> Why their developer selected that?
> Is there any special reason?

That would be questions for the developer(s).  As an end-user,
the only answer I can give is, it is that way because that is
the way it is.

-- 
 GNU/Linux user #557453
Keyboard not detected! Press any key to continue...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem running Python 3.5.2 on school network PC

2016-12-15 Thread Wildman via Python-list
On Thu, 15 Dec 2016 11:11:51 -0500, Jed Mack wrote:

> We are having a problem running Python 3.5.2 on Windows 10 x64 computers,
> which are members of a school network.
> 
> 
> 
> The program seems to install correctly, but when we try to run the program
> it stops and give an error message saying:
> 
> 
> 
> *Fatal Python error: Py_Initialize: unable to load the file system codec*
> 
> *Traceback (most recent call last):*
> 
> *  File "C:\Program Files\Python35\lib\encodings\__init__.py", line 31, in<
> module>*
> 
> *zipimport.ZipImportError: can't find module 'codecs'*
> 
> 
> 
> 
> 
> On a Windows 7 PCs, on the same network, the program runs with no problems.
> 
> 
> 
> We have no one here who is familiar with Python.  Do you have any
> additional information on this error, and suggestions for fixing it?
> 
> 
> 
> We have a teacher who needs this program on Windows 10 PCs for students to
> use beginning January 3.
> 
> 
> 
> Thanks,
> 
> Jed Mack

You might try adding the installation folders to the path, if it
hasn't been done already.  Change 'python' to the actual folder name.

C:\python
C:\python\Lib\site-packages
C:\python\Scripts

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CLP stats: last 500 posts

2016-12-11 Thread Wildman via Python-list
On Sun, 11 Dec 2016 12:03:07 -0500, DFS wrote:

> For this short stat version I only used the 'User-Agent' header.  I have 
> a longer version that uses both 'User-Agent' and 'X-Newsreader'
> 
> 
> You can put a conditional in place for now:
> 
> if s='giganews':
>   printStat("X-Newsreader","News Readers",m)
> else:
>   printStat("User-Agent","User-Agents",m)

Thanks but I had already tried X-Newsreader and I got the
same result.  It is odd because if you look at my headers
there is an entry for User-Agent

User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
 git://git.gnome.org/pan2; x86_64-pc-linux-gnu)



-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CLP stats: last 500 posts

2016-12-11 Thread Wildman via Python-list
On Sat, 10 Dec 2016 12:31:33 -0500, DFS wrote:

> 

After correcting my stupid oversights, the code runs fine
up to the point where the user agents are printed.  I get
an error saying that 'User-Agent' is an unsupported header
field.  It must have something to do with giganews.  If I
use aioe.org I don't get the error and the user agents are
printed.

I don't think it is a problem with the code but any thoughts
why giganews is not playing nice?  And it is not related to
the python group.  I have tried on other groups and i get
the same error.  Here is the complete error message.

Traceback (most recent call last):
  File "./nntp.py", line 27, in 
printStat("User-Agent","User-Agents",m)
  File "./nntp.py", line 12, in printStat
r,d=n.xhdr(st,'%s-%s'%rg)
  File "/usr/lib/python2.7/nntplib.py", line 470, in xhdr
resp, lines = self.longcmd('XHDR ' + hdr + ' ' + str, file)
  File "/usr/lib/python2.7/nntplib.py", line 273, in longcmd
return self.getlongresp(file)
  File "/usr/lib/python2.7/nntplib.py", line 244, in getlongresp
resp = self.getresp()
  File "/usr/lib/python2.7/nntplib.py", line 229, in getresp
raise NNTPPermanentError(resp)
nntplib.NNTPPermanentError: 501 unsupported header field

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CLP stats: last 500 posts

2016-12-10 Thread Wildman via Python-list
On Sat, 10 Dec 2016 12:31:33 -0500, DFS wrote:

> On 12/10/2016 12:06 PM, Wildman wrote:
>> On Fri, 09 Dec 2016 16:07:16 -0500, DFS wrote:
>>
>>> code (py2.7)
>>> --
>>> import sys as y,nntplib as t,datetime as d
>>> s=''
>>> g=y.argv[1]
>>> n=t.NNTP(s,119,'','')
>>> r,a,b,e,gn=n.group(g)
>>> def printStat(st,hd,rg):
>>> r,d=n.xhdr(st,'%s-%s'%rg)
>>> p=[]
>>> for i in range(len(d)):
>>> v=d[i][1]
>>> if st=='Subject':v=v[4:] if v[:3]=='Re:' else v
>>> p.append(v)
>>> x=[(i,p.count(i)) for i in set(p)]
>>> x.sort(key=lambda s:(-s[1],s[0].lower()))
>>> print('Posts  %s %s'%(len(set(p)),hd))
>>> for v in x: print(' %s %s'%(v[1],v[0]))
>>> print
>>> print 'As of '+d.datetime.now().strftime("%I:%M%p %B %d, %Y") + '\n'
>>> m=(int(e)-int(y.argv[3])+1,int(e))
>>> printStat("From","Posters",m)
>>> printStat("Subject","Subjects",m)
>>> printStat("User-Agent","User-Agents",m)
>>> n.quit()
>>> --
>>>
>>> usage on Windows:
>>> $ python stats.py group last N
>>> $ python stats.py comp.lang.python last 500
>>
>> Do you happen to have a translation of the code that will
>> run on Linux?
>>
>> $ ./nntp.py comp.lang.python last 500
>> Traceback (most recent call last):
>>   File "./nntp.py", line 7, in 
>> n=t.NNTP(s,119,'','')
>>   File "/usr/lib/python2.7/nntplib.py", line 119, in __init__
>> self.sock = socket.create_connection((host, port))
>>   File "/usr/lib/python2.7/socket.py", line 553, in create_connection
>> for res in getaddrinfo(host, port, 0, SOCK_STREAM):
>> socket.gaierror: [Errno -2] Name or service not known
> 
> 
> That code runs unchanged on py2.7 on Linux (I just now tested it).
> 
> You just need to put in your own credentials for the newsserver, user 
> and password (lines 2 and 4).

OK, thanks.  That didn't occur to me although it should have.
 
-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CLP stats: last 500 posts

2016-12-10 Thread Wildman via Python-list
On Fri, 09 Dec 2016 16:07:16 -0500, DFS wrote:

> code (py2.7)
> --
> import sys as y,nntplib as t,datetime as d
> s=''
> g=y.argv[1]
> n=t.NNTP(s,119,'','')
> r,a,b,e,gn=n.group(g)
> def printStat(st,hd,rg):
>   r,d=n.xhdr(st,'%s-%s'%rg)
>   p=[]
>   for i in range(len(d)):
>   v=d[i][1]
>   if st=='Subject':v=v[4:] if v[:3]=='Re:' else v
>   p.append(v)
>   x=[(i,p.count(i)) for i in set(p)]
>   x.sort(key=lambda s:(-s[1],s[0].lower()))
>   print('Posts  %s %s'%(len(set(p)),hd))
>   for v in x: print(' %s %s'%(v[1],v[0]))
>   print
> print 'As of '+d.datetime.now().strftime("%I:%M%p %B %d, %Y") + '\n'
> m=(int(e)-int(y.argv[3])+1,int(e))
> printStat("From","Posters",m)
> printStat("Subject","Subjects",m)
> printStat("User-Agent","User-Agents",m)
> n.quit()
> --
> 
> usage on Windows:
> $ python stats.py group last N
> $ python stats.py comp.lang.python last 500

Do you happen to have a translation of the code that will
run on Linux?

$ ./nntp.py comp.lang.python last 500
Traceback (most recent call last):
  File "./nntp.py", line 7, in 
n=t.NNTP(s,119,'','')
  File "/usr/lib/python2.7/nntplib.py", line 119, in __init__
self.sock = socket.create_connection((host, port))
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Detect Linux Runlevel

2016-12-06 Thread Wildman via Python-list
On Tue, 06 Dec 2016 13:06:35 -0600, Tim Chase wrote:

>

I forgot to mention that I want to include your name in the
final script as a contributor, if that is ok.

You will get a cut of the royalties.  Lets see, how much is
20% of $0.00?  Well, I'll let my account work that out as
soon as she gets home from the grocery.

-- 
 GNU/Linux user #557453
The voices in my head may not be real
but they have some good ideas.
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   >