LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Playing with Python programs installed (Screenlets) (https://www.linuxquestions.org/questions/programming-9/playing-with-python-programs-installed-screenlets-4175607287/)

dedec0 06-04-2017 03:11 PM

Playing with Python programs installed (Screenlets)
 
Hello! (:

I have installed Screenlets (https://packages.debian.org/jessie/screenlets) and recently I decided to take a look at its code.

One Screenlet I use a lot is OutputScreenlet, which is installed in cd /usr/share/screenlets/Output/. There, there is OutputScreenlet.py (comes from the package) and there is OutputScreenlet.pyc, which does *not* come with the package.

1. To edit the .py file and run the modified version as that screenlet, should I remove the .pyc file? Will it the be rebuilt automatically?

2. If I have one instance of Output running, can I play with the source code and run other instances to test the new changes?

3. To run an instance of Output, is it enough to run './OutputScreenlet.py' from my terminal?

4. Any other things to note or comment?

hydrurga 06-05-2017 08:06 AM

I don't know how the screenlets structure is set up, but why don't you copy the whole Output directory to a new Dedec0 directory and see if the program auto recognises it as a new screenlet (you may have to also edit an installed list of screenlists somewhere in the configuration structure in order to recognise the new screenlet).

Once you've got that sorted out, you can muck around with your Dedec0 screenlet to your heart's content and, by doing so, answer most of your questions.

As regards pyc files: https://stackoverflow.com/questions/...-are-pyc-files

dedec0 06-05-2017 09:04 AM

Quote:

Originally Posted by hydrurga (Post 5719168)
I don't know how the screenlets structure is set up, but why don't you copy the whole Output directory to a new Dedec0 directory and see if the program auto recognises it as a new screenlet (you may have to also edit an installed list of screenlists somewhere in the configuration structure in order to recognise the new screenlet).

Once you've got that sorted out, you can muck around with your Dedec0 screenlet to your heart's content and, by doing so, answer most of your questions.

Stackoverflow is a bad site to find specific answers, as for my question. It does not answer me (or I did not understand) while, at the same time, writing much about things that either I knew or that are not so important for the question being made. Specifically, most questions made there can have simple and relatively short answers, but they usually receive long "answers" that only make the history more complicated, and each "answer" can have a silly collection of comments that should not be kept (or be shown) to the end of times.

Before asking the question here, I have read around a bit about pyc. I could not find the answer I wanted. With the information I gave above, I imagined that these were easy and direct questions to someone more familiar than myself with Python:

- Can I edit the .py file without touching the .pyc?

- Should I remove the .pyc and then edit the .py file?

- How should I treat running instances of a screenlet that is being edited? Or, in a similar question, how running instances will behave if the source code is changed?

hydrurga 06-05-2017 09:12 AM

Quote:

Originally Posted by dedec0 (Post 5719194)
I suspect that is not as simple.

(and the rest)

What happened to the old spirit of "Let's give that a go and see if it works"?

dedec0 06-05-2017 09:35 AM

Quote:

Originally Posted by hydrurga (Post 5719197)
(and the rest)
Quote:

Originally Posted by dedec0
I suspect that is not as simple.
What happened to the old spirit of "Let's give that a go and see if it works"?

Hahaha... my suspect was based on a few things I have seen with the screenlets daemon (or the main program) and a few things I saw while editing the Output source. It will not work (at least) because the name of the screenlet is in its source, and just changing it will leave gaps in the upper structure of that system. I do not know the details of this structure, but it is not a simple "all directories that exist in that folder are individual screenlets" - I am 70% sure of that.

Further, editing the source is easier and cannot have unexpected side effects like two different programs using the same DB/file/register/whatever that may also cause runtime bad side effects. Asking a simple (as much as possible) question about the problem is fine, I think.

hydrurga 06-05-2017 10:57 AM

Ok. 70% is pretty sure. :)

What I would do is back up the Output directory (so that you can easily get back to the originals if things go awry).

Then shut down the Screenlets application (you never know e.g. what caching and info save to files on exit it employs).

After that, edit the .py file to change something very minor e.g. one single letter of text output which will be observable on running the screenlet again). Save the file.

Start up the Screenlets application again, load the Output screenlet (if necessary) and see what happens.

Report back here with another Thumbs down or, if things go well, a Thumbs up.

dedec0 06-05-2017 12:54 PM

My 70% is something like: I think it is, although I do not have any much strong argument - just a few things I saw.

The backup of the Output directory is the .deb file. I keep all packages that I install. But I also made a local copy of the file ('cp *.py o.py.original').

I did experiment a bit with changes and tests. But the results were not easy to see. Sometimes the changed Output did not work at all. One thing I did not try is to remove the .pyc file. And my tries were not exaustive. This, together with the fact that I am not too familiar with Python, made me think about making a thread.

Searching around for the Screenlets project gave me a sad fact: its domain (screenlets.org) is not active anymore. It hosted several screenlets we could install. Further about the project, the most recent versions in SourceForge page (launchpad.net/screenlets) do not contain a fair set of screenlets, just the daemon+launcher+installer. So I firmly held onto the packages from which I installed the whole thing (came with some screenlets, Output included). The current version of Debian (V8 jessie) has the "not the most recent" in a package! 0.1.2-8: https://packages.debian.org/jessie/screenlets. Two people (probably related to Debian, I imagine) made changes in the OP screenlet, many are just reformating a few parts.

These findings and my (then) not so fresh idea about making a thread made me decide: this seems to be hard just because I know too little of Python and the Screenlets system. (is the "little" word correct in this sentence, with the meaning I intend?)

Well... I did not find (yet) the answer I imagined would exist. I will experiment more, then, there is no option left.

Whatever happens, and hoping only for good things, I will report here - and "upwardly"! :D hahaha

hydrurga 06-05-2017 01:05 PM

Quote:

Originally Posted by dedec0 (Post 5719284)
My 70% is something like: I think it is, although I do not have any much strong argument - just a few things I saw.

The backup of the Output directory is the .deb file. I keep all packages that I install. But I also made a local copy of the file ('cp *.py o.py.original').

I did experiment a bit with changes and tests. But the results were not easy to see. Sometimes the changed Output did not work at all. One thing I did not try is to remove the .pyc file. And my tries were not exaustive. This, together with the fact that I am not too familiar with Python, made me think about making a thread.

Searching around for the Screenlets project gave me a sad fact: its domain (screenlets.org) is not active anymore. It hosted several screenlets we could install. Further about the project, the most recent versions in SourceForge page do not contain a fair set of screenlets, just the daemon+launcher+installer. So I firmly held onto the packages from which I installed the whole thing (came with some screenlets, Output included). The current version of Debian (V8 jessie) has the "not the most recent" in a package! 0.1.2-8: https://packages.debian.org/jessie/screenlets. Two people (probably related to Debian, I imagine) made changes in the OP screenlet, many are just reformating a few parts.

These findings and my (then) not so fresh idea about making a thread made me decide: this seems to be hard just because I know too little of Python and the Screenlets system. (is the "little" word correct in this sentence, with the meaning I intend?)

Well... I did not find (yet) the answer I imagined would exist. I will experiment more, then, there is no option left.

Whatever happens, and hoping only for good things, I will report here - and "upwardly"! :D hahaha

Yup, I noticed that the domain was parked too. Shame.

The only reason that I've been an annoying guy and asked you to try out things is that the package is quite old and the chances that you'll find someone on a general Linux forum like LQ who has used it may not be high...

Perhaps contacting the folk who made the changes to the screenlet might be a good option too? It can be hit and miss, but I've found most developers to be very approachable and friendly.

dedec0 06-05-2017 04:16 PM

Quote:

Originally Posted by hydrurga (Post 5719290)
The only reason that I've been an annoying guy and asked you to try out things is that the package is quite old and the chances that you'll find someone on a general Linux forum like LQ who has used it may not be high...

Python is a language I would like to learn more - I carry this idea since years ago! But by testing like this is not a good path, I think. I should be reading one of the books I collected and thought could be interesting. Oh... O,o

But if other users in LQ do not use Screenlets or do not install it just to check, does not matter much. Although I specified the exact files I am poking (or thinking about poking), it can be (or could be) seen as an example of a general situation: a Python project installed on a debianish system.

(...)

Contacting the two that changed (at least) one screenlet... good idea, maybe. I did not consider doing it - yet. Maybe in the future (not necessarily far).

RockDoctor 06-06-2017 08:30 AM

Haven't used Screenlets, but I have had good luck in the past with other apps just deleting a .pyc file, editing the associated .py file, then re-running the .py file.
Possible useful reference: http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm

oOBetaTestOo-Steve 12-18-2017 07:46 PM

Screenlets and Widgets
 
Quote:

Originally Posted by hydrurga (Post 5719290)
Yup, I noticed that the domain was parked too. Shame.

Does this now mean that screenlets are dead, iam trying at the moment to change a screenlet for the better I hope, and publish it.

Dead as in no way to contact the original creator or to properly credit them for the work they have done.
Would I be better digging out the code for the Identical Kde widget?And altering that?

Iam under the impression the the screenlets are cross? platform? Ie you can run them on GNome as well as KDE.............
Ive not done a lot of digging in to Widgets/KDE and the ins and outs of them.

The item I talk off is the FolderView screenlet/widget.

Ive been sending some emails to the likes of launchpad and others no responce YET probably having come accross this post their will never be a reply?


All times are GMT -5. The time now is 11:18 AM.