LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-04-2017, 03:11 PM   #1
dedec0
Member
 
Registered: May 2007
Posts: 559

Rep: Reputation: 26
Question 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?
 
Old 06-05-2017, 08:06 AM   #2
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
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
 
Old 06-05-2017, 09:04 AM   #3
dedec0
Member
 
Registered: May 2007
Posts: 559

Original Poster
Rep: Reputation: 26
Question

Quote:
Originally Posted by hydrurga View Post
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?

Last edited by dedec0; 06-05-2017 at 09:15 AM.
 
Old 06-05-2017, 09:12 AM   #4
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Quote:
Originally Posted by dedec0 View Post
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"?
 
1 members found this post helpful.
Old 06-05-2017, 09:35 AM   #5
dedec0
Member
 
Registered: May 2007
Posts: 559

Original Poster
Rep: Reputation: 26
Thumbs down

Quote:
Originally Posted by hydrurga View Post
(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.
 
Old 06-05-2017, 10:57 AM   #6
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
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.
 
1 members found this post helpful.
Old 06-05-2017, 12:54 PM   #7
dedec0
Member
 
Registered: May 2007
Posts: 559

Original Poster
Rep: Reputation: 26
Post

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

Last edited by dedec0; 06-05-2017 at 01:26 PM.
 
Old 06-05-2017, 01:05 PM   #8
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Quote:
Originally Posted by dedec0 View Post
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"! 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.

Last edited by hydrurga; 06-05-2017 at 01:48 PM. Reason: Missing out words again...
 
1 members found this post helpful.
Old 06-05-2017, 04:16 PM   #9
dedec0
Member
 
Registered: May 2007
Posts: 559

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by hydrurga View Post
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).
 
Old 06-06-2017, 08:30 AM   #10
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Linux Mint, Ubuntu
Posts: 1,595

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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
 
  


Reply

Tags
python


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Screenlets for Ubuntu/Gnome - Screenlets.org Ineed2know Linux - General 5 06-30-2013 06:36 PM
[SOLVED] Screenlets on Xfce (GConf python module not found) 0zMe Slackware 11 03-30-2011 10:45 PM
[SOLVED] Is there a way to start screenlets on python 2.6? lampamp Linux - General 1 09-22-2009 05:57 PM
How do I make python programs run without entering the command python? trist007 Programming 5 03-22-2009 08:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration