Python application launcher (for Python code)

Deborah Swanson python at deborahswanson.net
Mon Feb 20 21:16:14 EST 2017


Steve D'Aprano wrote, on February 20, 2017 4:53 PM
> 
> On Tue, 21 Feb 2017 04:04 am, Deborah Swanson wrote:
> 
> > That's a good idea, you can do just about anything from a shell, and
I 
> > read that Linus Torvalds never uses anything except the shell.
> [...]
> > Since I will be in Windows for yet awhile, it would be ideal to find

> > an application that will work in both Windows and Linux, and maybe a

> > shell installed in Windows is the way to go.
> 
> Windows has a console application with a shell. It is pretty 
> bare bones, but it works. If I remember the steps correctly 
> (and hopefully some Windows user will step in and correct me 
> if I get it wrong):
> 
> Start menu > Run > type "cmd" ENTER

Yes, I'm familiar with Windows' shell. It's basically (pun intended)
unchanged since Windows 2.0, maybe all the way back to MSDOS, except for
the additions of new built-in commands. (Some of which are useful, but
most are pretty useless.)
 
> I'm told that serious Windows power users don't use cmd.exe 
> or command.com (or is it the other way around?) any more, 
> they use Powershell, but I know nothing about that.

Yes, I've used Powershell, a couple decades ago, but it would be a
learning curve I'd rather stay off of to go back to it now. I'd rather
spend the time and energy to get up and running in Linux. It was my plan
all along to migrate to Linux and mostly leave Windows behind, but that
plan ran into some delays. Mostly by my good PC breaking down, and my
health went downhill again, about the same time.  Funny how you can't
really schedule those things, or make them be over with because you want
them to be.

> If you're using Windows 10, you might look at Windows 
> Subsystem for Linux:
> 
> https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-
> ubuntu-on-windows/

I can't stand any opsys Mickeysoft made after Windows XP, and I'd rather
have Linux back again than to pay big bucks to buy both the software and
a new PC, just to fight with Windows 10 for a mere subset of Linux. 

I read about "Cooperative Linux" the other day, which runs concurrently
with Windows and doesn't require booting back and forth between them, or
anything like the resource-hogging virtualization system I had on my
good PC. Cooperative could be ideal for this ancient, low resource PC I
have for now, but I haven't thoroughly checked it out yet. Or simply
installing a Linux shell in Windows as Grant Edwards suggested, but that
seems fraught with problems. Maybe not, but if Cooperative works as
advertised, that's a better bet.

> > But even within the shell I'd
> > want something to act as a Python application launcher (see my
previous
> > post for details), although using just the shell itself to locate
and
> > launch Python code is an option.
> 
> Normally the way I would launch applications is:
> 
> - from the Start menu (yes, many Linux desktops have a Start menu);
> 
> - from the shell.
> 
> 
> The Start menu is configurable under Linux, although I've 
> never done so, I've always let the OS manage it.
> 
> At the shell, there are plenty of ways to organise things. It 
> depends on how you want to launch your apps:
> 
> 
> python path/to/my/application.py
> 
> python -m application.py
> 
> path/to/my/application.py
> 
> application.py

That may be so, and maybe what I want to do could be much more easily
done in Linux than it is in Windows. I really didn't get that far with
Python in Linux before my PC with Linux on it died, so I honestly just
don't know and hadn't thought about it. Quite possibly Cooperative Linux
is my ticket out of this mess. 

> except on Windows you might have to use python.exe or py.exe 
> instead of python.

I think my time is better spent getting Linux back one way or another,
I've tried several approaches in Windows XP and the tinkering needed to
make it work well just doesn't seem worth it to me.

> The first is the most flexible: you can organise your scripts 
> and applications however you like, wherever you like, and 
> then just explicitly run them.

The other thing that occurs to me is that it's relatively easy to run
processes concurrently in Linux, so I could have my "on_Open" macro
running while any other Python code is running. The "on_Open" macro
should be accessible by the other running Python processes, but I've
read enough by now to see that it can be done, but there's a bit to
learn about how to do it.
 
> The last is the trickiest: on Linux, the file application.py 
> needs three things:
> 
> - it must have the appropriate magic "hash bang" line as the 
> first line of the file;
> 
> - it must be flagged as executable;
> 
> - it must be located somewhere on the executable PATH.

Thanks, I've copied these items into my project file, hopefully to be
used soon. 

> I'm not sure what the Windows equivalents to that are.
 
Me neither, and I'm less than enthused about figuring it out.
 
> 
> 
> -- 
> Steve
> "Cheer up," they said, "things could be worse." So I cheered 
> up, and sure enough, things got worse.
> 

Thanks Steve. It's possible I've been going at this all wrong. Like it
or not, I have a Microsoft mindset, all the more deeply burned in from
working there as a software tester as long as I did, and much as I've
tried to shed that mindset I still don't always see the blinders til
someone else points out a better way. In Windows you likely would need
an application launcher to efficiently do what I described, and it might
be possible to easily do it all simply from a Linux shell. To be
determined. That's why I inititially asked an open-ended question, to
see what other people are doing, and I may have got too caught up with
people asking exactly what I wanted to do.




More information about the Python-list mailing list