Control stript which is runing in background.
Hi. I would like to make something like this: A python script would run headlessly in the background. I would like to control the script from the command line using other python scripts or from the python shell. >From time to time I would ask the main script to create a popup window with an >image or a plot. What would be the proper way to approach it. How to make communication between two scripts? Thank you. Petro. -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
On 2020-12-31 10:43, Petro wrote: Hi. I would like to make something like this: A python script would run headlessly in the background. I would like to control the script from the command line using other python scripts or from the python shell. From time to time I would ask the main script to create a popup window with an image or a plot. What would be the proper way to approach it. How to make communication between two scripts? For communication, a socket would work. There are examples of a simple socket server and a simple socket client in the Python docs for the 'socket' module. -- https://mail.python.org/mailman/listinfo/python-list
ANN: unicode 2.8
unicode is a simple python command line utility that displays properties for a given unicode character, or searches unicode database for a given name. It was written with Linux in mind, but should work almost everywhere (including MS Windows and MacOSX), UTF-8 console is recommended. ˙pɹɐpuɐʇs əpoɔı̣uՈ əɥʇ ɟo əsn pəɔuɐʌpɐ puɐ səldı̣ɔuı̣ɹd əɥʇ ɓuı̣ʇɐɹʇsuoɯəp looʇ ɔı̣ʇɔɐpı̣p ʇuəlləɔxə uɐ sı̣ ʇI ˙sʇuı̣odəpoɔ ʇuəɹəɟɟı̣p ʎləʇəldɯoɔ ɓuı̣sn əlı̣ɥʍ 'sɥdʎlɓ ɟo ɯɐəɹʇs ɹɐlı̣ɯı̣s ʎllɐnsı̣ʌ oʇuı̣ ʇxəʇ əɥʇ ʇɹəʌuoɔ oʇ pɹɐpuɐʇs əpoɔı̣uՈ əɥʇ ɟo ɹəʍod llnɟ əɥʇ sʇı̣oldxə ʇɐɥʇ 'ʎʇı̣lı̣ʇn ,əpoɔɐɹɐd, oslɐ suı̣ɐʇuoɔ əɓɐʞɔɐd əɥ⊥ Changes since previous versions: * display ASCII table (either traditional with --ascii or the new EU–UK Trade and Cooperation Agreement version with --brexit-ascii) * minor bug fixes URL: http://kassiopeia.juls.savba.sk/~garabik/software/unicode.html License: GPL v3 Installation: pip install unicode -- --- | Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ | | __..--^^^--..__garabik @ kassiopeia.juls.savba.sk | --- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! -- https://mail.python.org/mailman/listinfo/python-list
Re: help
i am trying to open it by just left clicking the file in file explorer and
i tried right clicking it and then pressing open with python 3.9.1 64-bit
On Thu, 31 Dec 2020 at 00:52, Mats Wichmann wrote:
> On 12/30/20 2:14 PM, BearGod777 wrote:
> > every time i try and open a .py file it just ciomes up with either
> modify,
> > uninstall or repair. i have tried every single one of these and i have
> > tried to install another version (it couldnt run on that version) and it
> > just doesnt load up. if i try and open a new file it works but if i try
> and
> > open a file that my friend made it just comes up with those options.
> please
> > help
>
> you're rerunning the installer, don't do that.
>
> that sounds rude. but isn't meant to be. somehow in recent times, the
> installer program - whose job it is indeed to install, uninstall, repair
> - is getting picked up by Windows when you try to run Python in certain
> ways - the installer should certainly not be getting associated with .py
> files as the way to run them. It might help diagnose how this happens if
> you describe what you're doing ("try and open a .py file" doesn't say
> enough, how are you trying to open it?)
>
> open a command shell (cmd.exe or powershell) and run your script foo.py
> with "py foo.py", assuming you chose to install the Python Launcher,
> which you should do if using the Python that comes from python.org.
>
>
>
>
--
https://mail.python.org/mailman/listinfo/python-list
Re: help
On 12/31/20 8:11 AM, BearGod777 wrote: i am trying to open it by just left clicking the file in file explorer and i tried right clicking it and then pressing open with python 3.9.1 64-bit That *shouldn't* open the installer... (you can actually remove the installer file once you're done installing, it can maybe reduce some confusion). What you're doing is going to give you probably unexpected results anyway. Here's why: (when it's set up properly) when clicking from explorer Windows will create a window to run the Python interpreter in, and when your script finishes, Python quits. Windows will take that as a clue that the window is no longer needed, and it will be discarded. This will usually have the visual effect of a window flashing onto the screen and then vanishing, as if things were broken, but they're not. Only a Python script that is written to manage a display window, is going to stay around. An old is to add an input() call at the end of your script, so it waits for you to hit the enter key before finishing, and that will leave the window open) Either run your scripts from a command shell... Or use an editor or IDE that has an integrated way to run your programs there in the editor's environment - here the IDE manages the windows so you don't get the opens-then-closes effect. Hope this helps. -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
Il 31/12/2020 11:43, Petro ha scritto: Hi. I would like to make something like this: A python script would run headlessly in the background. I would like to control the script from the command line using other python scripts or from the python shell. From time to time I would ask the main script to create a popup window with an image or a plot. What would be the proper way to approach it. How to make communication between two scripts? Thank you. Petro. using named pipes would be an alternative. A small example that produces an echo for windows. For linux it's simpler using os.mkfifo: # - import win32pipe as wp, win32file as wf pfile = r'\\.\pipe\mypipe' how = 0 data: bytes while True: pipe = wp.CreateNamedPipe(pfile, wp.PIPE_ACCESS_DUPLEX, wp.PIPE_TYPE_BYTE | wp.PIPE_READMODE_BYTE | wp.PIPE_WAIT, wp.PIPE_UNLIMITED_INSTANCES, 0x, 0x, 0, None) if pipe: wp.ConnectNamedPipe(pipe, None) while True: try: rv, data = wf.ReadFile(pipe, 1024) except: wf.CloseHandle(pipe) break else: print(data.decode(), end='') else: break # - you can pass commands to it this way too: $> echo "print log" > \\.\pipe\mypipe -- https://mail.python.org/mailman/listinfo/python-list
Re: ANN: unicode 2.8
On 12/31/2020 9:36 AM, [email protected] wrote: unicode is a simple python command line utility that displays properties for a given unicode character, or searches unicode database for a given name. ... Changes since previous versions: * display ASCII table (either traditional with --ascii or the new EU–UK Trade and Cooperation Agreement version with --brexit-ascii) Are you reproducing it with bugs included? How is that of any use to anyone? A tweet linking the treaty annex page https://twitter.com/thejsa_/status/1343291595899207681 A stackoverflow question and discussion of the bugs and oddities. https://politics.stackexchange.com/questions/61178/why-does-the-eu-uk-trade-deal-have-the-7-bit-ascii-table-as-an-appendix The likely answer is that the treaty writers copy-pasted from decades-old docs and could not be bothered to link to the actual ISO standard. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
On 31Dec2020 18:07, jak wrote: >Il 31/12/2020 11:43, Petro ha scritto: >>I would like to make something like this: >>A python script would run headlessly in the background. >>I would like to control the script from the command line using other python >>scripts or from the python shell. >> From time to time I would ask the main script to create a popup window with >> an image or a plot. >>What would be the proper way to approach it. How to make communication >>between two scripts? > >using named pipes would be an alternative. A small example that >produces an echo for windows. A Windows named pipe seems to be more like a UNIX-side "UNIX domain socket" than a UNIX side "named pipe". >For linux it's simpler using os.mkfifo: Not really. For Linux (and of course other UNIXen) you really want a UNIX domain socket, not a a name pipe (as from mkfifo). The reason is that a socket (and a Windows pipe, from my limited understanding) creates a new distinct connection when you open it. (The other end has to accept that connection, at least in UNIX). The problem with a UNIX pipe is that every client (your command line control script) _share_ the same pipe - if two scripts un at once there will be a failure. If you contrive some locking scheme then you can share a named pipe in UNIX because only once client will use the pipe at a time. Just something to keep in mind. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
Il 31/12/2020 22:43, Cameron Simpson ha scritto: On 31Dec2020 18:07, jak wrote: Il 31/12/2020 11:43, Petro ha scritto: I would like to make something like this: A python script would run headlessly in the background. I would like to control the script from the command line using other python scripts or from the python shell. From time to time I would ask the main script to create a popup window with an image or a plot. What would be the proper way to approach it. How to make communication between two scripts? using named pipes would be an alternative. A small example that produces an echo for windows. A Windows named pipe seems to be more like a UNIX-side "UNIX domain socket" than a UNIX side "named pipe". For linux it's simpler using os.mkfifo: Not really. For Linux (and of course other UNIXen) you really want a UNIX domain socket, not a a name pipe (as from mkfifo). The reason is that a socket (and a Windows pipe, from my limited understanding) creates a new distinct connection when you open it. (The other end has to accept that connection, at least in UNIX). - The problem with a UNIX pipe is that every client (your command line control script) _share_ the same pipe - if two scripts un at once there will be a failure. If you contrive some locking scheme then you can share a named pipe in UNIX because only once client will use the pipe at a time. This is not completely true, in fact requests can be queued as they would be with sockets and it is their real job. The most important difference is that sockets are a limited resource on a system. Just something to keep in mind. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Funny error message
When I run python from the command line and generate an error I get the
following:
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> z
/home/bob/.local/lib/python3.8/site-packages/requests/__init__.py:89:
RequestsDependencyWarning: urllib3 (1.24.3) or chardet (4.0.0) doesn't
match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
File "", line 1, in
NameError: name 'z' is not defined
I understand "z in not defined" ... but what's with the warnings?
--
Listen to my FREE CD at http://www.mellowood.ca/music/cedars
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: [email protected]
WWW: http://www.mellowood.ca
--
https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
... but this won't be the problem the OP may encounter if its intention is to create a script to command another one that is running. It will be sufficient to limit the write permissions to the pipe file to himself ... perhaps protecting the pipe file inside a directory with stickibits set. -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
On 2021-01-01 at 00:45:52 +0100, Regarding "Re: Control stript which is runing in background.," jak wrote: > ... but this won't be the problem the OP may encounter if its intention is > to create a script to command another one that is running. It will be > sufficient to limit the write permissions to the pipe file to himself ... > perhaps protecting the pipe file inside a directory with stickibits set. Most of the time, I have several shells open, often with their own background jobs running. Limiting write permission on the pipe to "me" wouldn't prevent concurrent access. -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
Il 01/01/2021 00:58, [email protected] ha scritto: Most of the time, I have several shells open, often with their own background jobs running. Limiting write permission on the pipe to "me" wouldn't prevent concurrent access. This is true but there would be no difference if this happened through a socket. -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
On 01Jan2021 01:21, jak wrote: >Il 01/01/2021 00:58, [email protected] ha scritto: >>Most of the time, I have several shells open, often with their own >>background jobs running. Limiting write permission on the pipe to "me" >>wouldn't prevent concurrent access. > >This is true but there would be no difference if this happened through >a socket. Accessing a socket makes a distinct separate data connection - other openers do not conflict with it. That's the critical difference between a socket and a pipe in terms of functionality, and why sockets have a connect/accept step. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
Il 01/01/2021 01:43, Cameron Simpson ha scritto: On 01Jan2021 01:21, jak wrote: Il 01/01/2021 00:58, [email protected] ha scritto: Most of the time, I have several shells open, often with their own background jobs running. Limiting write permission on the pipe to "me" wouldn't prevent concurrent access. This is true but there would be no difference if this happened through a socket. Accessing a socket makes a distinct separate data connection - other openers do not conflict with it. That's the critical difference between a socket and a pipe in terms of functionality, and why sockets have a connect/accept step. Cheers, Cameron Simpson Maybe the fact that I'm not English and I don't know the language well doesn't allow me to express myself clearly. Try it one more time: The OP would like to give some command to a script that is running. How? With a script that sends commands to it. One of the ways, as mentioned, is by using a mini socket server. Given the needs of the OP and the fact that sockets are a limited resource in a system, I took the liberty of proposing a simple alternative: using a named pipe, also because, IMO, sockets, in this case, are an overkill. with a few lines of code in a thread in the running script they can allow it to receive commands: #- import os, errno fnpipe = 'cmdpipe' try: os.mkfifo(fnpipe) except OSError as e: if e.errno != errno.EEXIST: raise while True: with open(fnpipe, 'rt', 1) as fifo: for line in fifo: print(line, ends='') #- Running the command: $ cat bible.txt > cmdpipe & cat bible.txt > cmdpipe & cat bible.txt > cmdpipe the three texts do not mix. IMO, the OP should be enough. after that, I know that a pipe is more like a queue than a soket and in this case a socket, IMO, is wasted. greetings, hoping to have been clearer than before. -- https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
On 2021-01-01 at 03:43:43 +0100, Regarding "Re: Control stript which is runing in background.," jak wrote: > Il 01/01/2021 01:43, Cameron Simpson ha scritto: > > On 01Jan2021 01:21, jak wrote: > > > Il 01/01/2021 00:58, [email protected] ha scritto: > > > > Most of the time, I have several shells open, often with their own > > > > background jobs running. Limiting write permission on the pipe to "me" > > > > wouldn't prevent concurrent access. > > > > > > This is true but there would be no difference if this happened through > > > a socket. > > > > Accessing a socket makes a distinct separate data connection - other > > openers do not conflict with it. That's the critical difference between > > a socket and a pipe in terms of functionality, and why sockets have a > > connect/accept step. > > > > Cheers, > > Cameron Simpson > > > > Maybe the fact that I'm not English and I don't know the language well > doesn't allow me to express myself clearly. Try it one more time: > The OP would like to give some command to a script that is running. How? > With a script that sends commands to it. One of the ways, as mentioned, > is by using a mini socket server. Given the needs of the OP and the fact > that sockets are a limited resource in a system, I took the liberty of > proposing a simple alternative: using a named pipe, also because, IMO, > sockets, in this case, are an overkill. with a few lines of code in a > thread in the running script they can allow it to receive commands: > #- > import os, errno > > fnpipe = 'cmdpipe' > > try: > os.mkfifo(fnpipe) > except OSError as e: > if e.errno != errno.EEXIST: > raise > while True: > with open(fnpipe, 'rt', 1) as fifo: > for line in fifo: > print(line, ends='') > #- > > Running the command: > > $ cat bible.txt > cmdpipe & cat bible.txt > cmdpipe & cat bible.txt > > cmdpipe > > the three texts do not mix. IMO, the OP should be enough. after that, I > know that a pipe is more like a queue than a soket and in this case a > socket, IMO, is wasted. Only the OP knows for sure. :-) Does the server send data back to the client that made the request? Are the requests (and the responses, if any) small enough to be sent/received atomically? *If* the answers are no and yes, then you're right, a named pipe would be good enough. If not, then a socket *might* be better. Until the OP clarifies, we can't tell. > greetings, hoping to have been clearer than before. I think you were clear enough before, but you may not have considered things the OP did not specify. One of the hardest parts of software development is understanding and specifying the actual problem to be solved. I've never done that in a second language (I'm nowhere near fluent in anything other than English); I can only imagine the extra layers of complexity. -- https://mail.python.org/mailman/listinfo/python-list
Re: Funny error message
On 1/1/21 11:46 AM, Bob van der Poel wrote:
> When I run python from the command line and generate an error I get the
> following:
>
> Python 3.8.5 (default, Jul 28 2020, 12:59:40)
> [GCC 9.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
z
> /home/bob/.local/lib/python3.8/site-packages/requests/__init__.py:89:
> RequestsDependencyWarning: urllib3 (1.24.3) or chardet (4.0.0) doesn't
> match a supported version!
> warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
> Traceback (most recent call last):
> File "", line 1, in
> NameError: name 'z' is not defined
>
> I understand "z in not defined" ... but what's with the warnings?
The implication is that there is a version-mismatch between Python 3.8
and whichever urllib3 and chardet libraries currently installed.
Recommend updating the system, container, or venv: either Python, pip3
of the two and/or requests or html-parser [as appropriate to the
installed libraries - see below], or both/all.
System here runs as-expected:
dn $ ... python
Python 3.9.1 (default, Dec 8 2020, 00:00:00)
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> z
Traceback (most recent call last):
File "", line 1, in
NameError: name 'z' is not defined
>>> import chardet
>>> import urllib3
>>> exit()
dn $ ... pip show chardet urllib3
Name: chardet
Version: 3.0.4
Summary: Universal encoding detector for Python 2 and 3
Home-page: https://github.com/chardet/chardet
Author: Mark Pilgrim
Author-email: [email protected]
License: LGPL
Location: /usr/lib/python3.9/site-packages
Requires:
Required-by: html5-parser, requests
---
Name: urllib3
Version: 1.25.8
Summary: HTTP library with thread-safe connection pooling, file post,
and more.
Home-page: https://urllib3.readthedocs.io/
Author: Andrey Petrov
Author-email: [email protected]
License: MIT
Location: /usr/lib/python3.9/site-packages
Requires:
Required-by: requests
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list
Re: Control stript which is runing in background.
jak writes:
Running the command:
$ cat bible.txt > cmdpipe & cat bible.txt > cmdpipe & cat bible.txt > cmdpipe
the three texts do not mix
The three texts do not mix as long at the contents of bible.txt is short
enough (and provided `cat' only calls `write' once). In the POSIX
specification, the manual page for the `write' system call describes
writing to a pipe or FIFO as follows:
Write requests of {PIPE_BUF} bytes or less shall not be interleaved
with data from other processes doing writes on the same pipe. Writes
of greater than {PIPE_BUF} bytes may have data interleaved, on
arbitrary boundaries, with writes by other processes, whether or not
the O_NONBLOCK flag of the file status flags is set.
--
Alan Bawden
--
https://mail.python.org/mailman/listinfo/python-list
