deragon / autopoweroff

Manage automatic poweroff and other actions (suspend / custom) when specific conditions are reunited.
GNU General Public License v2.0
52 stars 7 forks source link

diskactivity #7

Closed rac8006 closed 4 years ago

rac8006 commented 5 years ago

minor error in apoObeserverDisk.py when handling more than one disk.

jamesearl commented 4 years ago

Hey @rac8006 just glancing at this PR, it looks like maybe the files you changed/added are in the wrong location in the project? I'm seeing all additions with no modifications, why I'm pointing it out. Could be wrong though!

rac8006 commented 4 years ago

I'm not sure. I thought that I committed the files. I'm not that familiar with github. I'm going to have to look at what I changed. It has been almost a year since I made that changes. I'm running the code with no problems.

jamesearl commented 4 years ago

Yeah, I realize I responded to a pretty old PR, but I was looking for something similar so I thought I might follow up :D

deragon commented 4 years ago

Author here. Yes, I attempted to merge the code of @rac8006 (thank you for the contribution), but it was at the wrong place and merging became too complicated. My personal life keeps me too busy to sort this out, so I abandoned the idea. I apologize for not being able to do more but at this point, I can only accept proper code, ready to be merge, to add it to the master branch.

rac8006 commented 4 years ago

What is the right place?  I thought I checked it out.  then committed the changes?  What is the proper sequence?

-----Original Message----- From: Hans Deragon notifications@github.com To: deragon/autopoweroff autopoweroff@noreply.github.com Cc: rac8006 rac8006@aol.com; Mention mention@noreply.github.com Sent: Tue, Feb 25, 2020 7:23 am Subject: Re: [deragon/autopoweroff] diskactivity (#7)

Author here. Yes, I attempted to merge the code of @rac8006 (thank you for the contribution), but it was at the wrong place and merging became too complicated. My personal life keeps me too busy to sort this out, so I abandoned the idea. I apologize for not being able to do more but at this point, I can only accept proper code, ready to be merge, to add it to the master branch.— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

deragon commented 4 years ago

Files need to be in the same directories, committed prior their previous version to continue the history. I suggest that you learn about Git and more generally, how version control is done. There are many resources on the net about this. I am very sorry I cannot spend more time on this.

rac8006 commented 4 years ago

I don’t know how to remove my fork of the autopoweroffd. At my age (77) I don’t understand github. In all of the time I’ve been working on this code. I didn’t understand how the .in files worked. I think I now know how it works. I was always editing both files. I finally figured how to create the build.deb file. Though the postinstall would not run until I put ./postinstall in the makefile.in. Also I didn’t have lintian app installed.

Since you listed that you wanted to start using system below is the necessary code to accomplish this task.

The command to start autopoweroff under system.d is as follows.

After some searching I could not understand how to get the build process to create the directory and copy the file

Into the build direcoty when you sh builddeb --make

systemctl start autopoweroff

systemctl stop autopoweroff

in the build process you need to create the following directory.

/etc/systemd/system/multi-user.target.wants

I that directory you need to put a file called autopoweroff.service

Below is what the contents of the file need to contain everything between the words begin and end.

Filename = autopoweroff.service

begin

[Unit]

Description=autopoweroff daemon

After=network.target

[Service]

Type=simple

User=root

NotifyAccess=all

PIDFile=/var/run/autopoweroffd/autopoweroffd.pid

ExecStart=/usr/sbin/autopoweroffd start

RemainAfterExit=true

ExecStop=/usr/sbin/autopoweroffd stop

ExecReload=/usr/sbin/autopoweroffd reload

[Install]

WantedBy=multi-user.target

end

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

deragon commented 4 years ago

Quickly, .in files are the source, The other files are generated when running the following:

aclocal
automake
autoconf
configure --prefix=/tmp/autopoweroff

Essentially, .in files contains macros starting with @ that are replaced by configure according to the platform it is being built for. It is not ideal and slowly, I want to get rid of it. But it is not easy. GNU Autotools is confusing and when you stop working with it for years, coming back to it is hard.

deragon commented 4 years ago

Also in the master branch, I changed a lot recently. I created ApoObserverResources.py. You might want to move your code there.

rac8006 commented 4 years ago

I always wondered why when I did make everything was updated. I was always editing the py file.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Monday, September 7, 2020 1:53 PM To: deragon/autopoweroff Cc: rac8006; Mention Subject: Re: [deragon/autopoweroff] diskactivity (#7)

Quickly, .in files are the source, The other files are generated when running the following: aclocal automake autoconf configure --prefix=/tmp/autopoweroff Essentially, .in files contains macros starting with @ that are replaced by configure according to the platform it is being built for. It is not ideal and slowly, I want to get rid of it. But it is not easy. GNU Autotools is confusing and when you stop working with it for years, coming back to it is hard. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

rac8006 commented 4 years ago

I downloaded the latest source I thought. But it didn’t have the ApoObserverResources.py file. I also assume that you changed the glade file. Well I was able to download the master zip file. It does contain the changed files.
I’ll look at the changes and try to move them to 3.1.0. I can’t test 3.2.1 because I can’t install 3.6 python. I tried running 3.2.1 files and found that I didn’t have the correct python version. I’m unable to find the correct version for Debian 9.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Monday, September 7, 2020 1:54 PM To: deragon/autopoweroff Cc: rac8006; Mention Subject: Re: [deragon/autopoweroff] diskactivity (#7)

Also in the master branch, I changed a lot recently. I created ApoObserverResources.py. You might want to move your code there. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

deragon commented 4 years ago

The files is in the master branch. See at:

I fail to figure out why you do not see it. You have to be in the master branch. You are probably in your own branch... Or if you forked Autopoweroff, obviously your fork is not up to date. And in Github, the did not made it easy to sync a fork.... Ugh... Without knowledge of Git, it is not possible to sync it.

Here are the instructions I use to perform a sync...

KEEPING A FORK UP TO DATE - APPLIES TO GITHUB FORKS - UPDATE ══════════════════════════════════════════════════════════════════════════════

https://gist.github.com/CristinaSolana/1885435

  1. Clone your fork:

    git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

  2. Add remote from original repository in your forked repository:

    cd into/cloned/fork-repo git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git git fetch upstream

  3. Updating your fork from original repo to keep up with their changes:

    git pull git pull upstream master

rac8006 commented 4 years ago

Thanks for the response. I thought that I said in the previous email that I did download the master.zip file. It does Contain all of the new files. I haven’t done anything with the GitHub files that I pulled last year. I’m currently working with the 3.1.0 version. I’ve got my changes My changes and I tried to also port the changes that you made to 3.2.1. But not the python 3 changes. As I said I can’t get version of python 3 that will run your 3.2.1 code.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Monday, September 7, 2020 7:55 PM To: deragon/autopoweroff Cc: rac8006; Mention Subject: Re: [deragon/autopoweroff] diskactivity (#7)

The files is in the master branch. See at: • https://github.com/deragon/autopoweroff/tree/master/python/moduleshttps://github.com/deragon/autopoweroff/blob/master/python/modules/ApoObserverResources.py I fail to figure out why you do not see it. You have to be in the master branch. You are probably in your own branch... Or if you forked Autopoweroff, obviously your fork is not up to date. And in Github, the did not made it easy to sync a fork.... Ugh... Without knowledge of Git, it is not possible to sync it. Here are the instructions I use to perform a sync... KEEPING A FORK UP TO DATE - APPLIES TO GITHUB FORKS - UPDATE ══════════════════════════════════════════════════════════════════════════════ https://gist.github.com/CristinaSolana/1885435

  1. Clone your fork: git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

  2. Add remote from original repository in your forked repository: cd into/cloned/fork-repo

git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git

git fetch upstream

  1. Updating your fork from original repo to keep up with their changes: git pull

git pull upstream master

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

rac8006 commented 4 years ago

This has been fun not. After downloading the master files. I thought I might port your changes back to 3.1.0 since I can’t seem to get the code to work with python3.5. I then decided to download python3.7 source and build it since I can’t find that version to download the binaries. After building and installing the python3.7 binaries. I tried to run the autopoweroff-gui but get a module missing gi. So I reverted back to python3.5 and the autopoweroffgui worked. I then tried to run autopoweroffd start. It failed on the f in the print statement to display the logfile. So I then changed to python3.7 and ran the autopoweroff start and get an error psutil missing. It seems that the python3.7 that I built does not have the dist-packages folder.

When version of python are you using?

Sorry for rambling.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Monday, September 7, 2020 7:55 PM To: deragon/autopoweroff Cc: rac8006; Mention Subject: Re: [deragon/autopoweroff] diskactivity (#7)

The files is in the master branch. See at: • https://github.com/deragon/autopoweroff/tree/master/python/moduleshttps://github.com/deragon/autopoweroff/blob/master/python/modules/ApoObserverResources.py I fail to figure out why you do not see it. You have to be in the master branch. You are probably in your own branch... Or if you forked Autopoweroff, obviously your fork is not up to date. And in Github, the did not made it easy to sync a fork.... Ugh... Without knowledge of Git, it is not possible to sync it. Here are the instructions I use to perform a sync... KEEPING A FORK UP TO DATE - APPLIES TO GITHUB FORKS - UPDATE ══════════════════════════════════════════════════════════════════════════════ https://gist.github.com/CristinaSolana/1885435

  1. Clone your fork: git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

  2. Add remote from original repository in your forked repository: cd into/cloned/fork-repo

git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git

git fetch upstream

  1. Updating your fork from original repo to keep up with their changes: git pull

git pull upstream master

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

rac8006 commented 4 years ago

I’ve been able to port the diskactivity changes to the master source files. While testing I could not get the system to shutdown even thought there was not disk activity. The problem seems o have been the cpuUsage. Even though it is disabled it was retuning false. The status function checks for cpuusage >= CpuUsageConfigurationLimit. The limit is 0 because it is disabled. So it will always return False. I changed the logic to test basically return True if cpuUsage is disabled.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Monday, September 7, 2020 7:55 PM To: deragon/autopoweroff Cc: rac8006; Mention Subject: Re: [deragon/autopoweroff] diskactivity (#7)

The files is in the master branch. See at: • https://github.com/deragon/autopoweroff/tree/master/python/moduleshttps://github.com/deragon/autopoweroff/blob/master/python/modules/ApoObserverResources.py I fail to figure out why you do not see it. You have to be in the master branch. You are probably in your own branch... Or if you forked Autopoweroff, obviously your fork is not up to date. And in Github, the did not made it easy to sync a fork.... Ugh... Without knowledge of Git, it is not possible to sync it. Here are the instructions I use to perform a sync... KEEPING A FORK UP TO DATE - APPLIES TO GITHUB FORKS - UPDATE ══════════════════════════════════════════════════════════════════════════════ https://gist.github.com/CristinaSolana/1885435

  1. Clone your fork: git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

  2. Add remote from original repository in your forked repository: cd into/cloned/fork-repo

git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git

git fetch upstream

  1. Updating your fork from original repo to keep up with their changes: git pull

git pull upstream master

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

deragon commented 4 years ago

BUG! And it is fixed now. Please download the latest code from master to get the fix about the CPU usage condition working when disabled. Thank you for reporting the problem and my apologies for the bug.

rac8006 commented 4 years ago

Just removing this pull

deragon commented 4 years ago

As far as I can tell, any Python 3 should work... What is the distribution you are using? I am using Ubuntu 20.04 which comes with Python 3.8.2. I had to move to Python 3 since it has been 10 years that they deprecated Python 2 and in 2020, Python 2 is officially dead. I was actually very late at migrating to Python 3; it should have been done years ago.

rac8006 commented 4 years ago

I’m running Debian 9. I downloaded python3.8 built it and got it working. I had to play aound getting psutil installed a it was not in the build thst I did. I now have the latest master source updated to run autopoweroffd with diskactivity. So far it it sleeps when it is supposed to sleep. The only thing I’m Not sure of is after going to sleep and you wake it up it will go to sleep almost immediately. I think the problem is that the lastdiskeventtime needs to be Set to the current time when the system wakes up. I will try again to pull and post my changes. I deleted my previous pull.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Saturday, September 12, 2020 3:51 PM To: deragon/autopoweroff Cc: rac8006; State change Subject: Re: [deragon/autopoweroff] diskactivity (#7)

As far as I can tell, any Python 3 should work... What is the distribution you are using? I am using Ubuntu 20.04 which comes with Python 3.8.2. I had to move to Python 3 since it has been 10 years that they deprecated Python 2 and in 2020, Python 2 is officially dead. I was actually very late at migrating to Python 3; it should have been done years ago. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

rac8006 commented 4 years ago

I looked at your change. Where does cpuUsageConfiguredLimit get set to “disabled” From what I saw in the code it gets set to 0 if disabled. I only see One file changed in the last 3 hours. Did I miss something?

Sent from Mail for Windows 10

From: Hans Deragon Sent: Saturday, September 12, 2020 3:51 PM To: deragon/autopoweroff Cc: rac8006; State change Subject: Re: [deragon/autopoweroff] diskactivity (#7)

As far as I can tell, any Python 3 should work... What is the distribution you are using? I am using Ubuntu 20.04 which comes with Python 3.8.2. I had to move to Python 3 since it has been 10 years that they deprecated Python 2 and in 2020, Python 2 is officially dead. I was actually very late at migrating to Python 3; it should have been done years ago. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

rac8006 commented 4 years ago

Never mind I see what you did. Sorry.

Sent from Mail for Windows 10

From: Hans Deragon Sent: Saturday, September 12, 2020 3:51 PM To: deragon/autopoweroff Cc: rac8006; State change Subject: Re: [deragon/autopoweroff] diskactivity (#7)

As far as I can tell, any Python 3 should work... What is the distribution you are using? I am using Ubuntu 20.04 which comes with Python 3.8.2. I had to move to Python 3 since it has been 10 years that they deprecated Python 2 and in 2020, Python 2 is officially dead. I was actually very late at migrating to Python 3; it should have been done years ago. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus