Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh host monitor while start #671

Merged

Conversation

srbhss
Copy link
Contributor

@srbhss srbhss commented Mar 29, 2020

issue #163

Call updateRequest method when the object of class HostMonitorDockWidget is constructed.

@srbhss srbhss marked this pull request as ready for review March 30, 2020 09:22
@srbhss
Copy link
Contributor Author

srbhss commented Mar 30, 2020

@gregdenton @bcipriano sir I think this would trigger refresh. But this is not configurable, please guide me on how to make this configurable.

@srbhss srbhss closed this Mar 30, 2020
@srbhss srbhss reopened this Mar 30, 2020
@bcipriano
Copy link
Collaborator

Sure thing. I think the mechanism you will want to use here is the QSettings system we already have in place.

Some relevant spots in the code:

In effect this allows us to distribute a default settings file (cuetopia.ini) that studio sysadmins can override by distributing their own custom version.

So I think we want to use this mechanism and add a new setting which controls whether Hosts auto-refresh on open.

Added check box for setting up triggered refresh on start
Call updateRequest method if TriggeredRefresh is enabled in setting.
@srbhss
Copy link
Contributor Author

srbhss commented Apr 3, 2020

@bcipriano @gregdenton Sir
This will resolve the issue. Please check if everything is looking fine.

@srbhss
Copy link
Contributor Author

srbhss commented Apr 5, 2020

Added check box (by default checked) to trigger a refresh on launch. This will make easier for users to toggle the settings.
Will it be a good feature ?
@bcipriano Sir

@bcipriano
Copy link
Collaborator

@srbhss Could you post a screenshot of the GUI changes you've made here?

@srbhss
Copy link
Contributor Author

srbhss commented Apr 7, 2020

Screenshot (4)
@bcipriano Sir
We can configure the 'refreshing on start' from this 'triggered-refresh' check box. Please comment if this is a good option or It would be better with something else.

@bcipriano
Copy link
Collaborator

@srbhss Thanks for the thoughtful reply.

I think that in almost all cases, a user will want "Auto refresh on launch" and "Auto refreshing while running" to have the same value. And for the rare cases when they don't, it will be easy to update the default setting or just toggle the checkbox.

So let's use just one dropbox, the existing "Auto-refresh" one.

@srbhss
Copy link
Contributor Author

srbhss commented Apr 11, 2020

@bcipriano Sir
Please check this again. I have set auto refresh 'ON' by default and integrated refresh on launch with it.
Did same with both "Host Monitor" and "Proc Monitor".

Copy link
Collaborator

@gregdenton gregdenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks srbhss. This change LGTM.

Copy link
Collaborator

@bcipriano bcipriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking mostly good!

I think there's a problem with the QtGui.qApp.settings.value() calls. In my environment at least, when AutoRefreshMonitorHost is set in the settings file, value() returns the value as a string. So if we saved 0 as the value, it is returned as '0' (a string) which is then interpreted as True by bool().

I think you need to int() the value first, before passing it to bool().

(I wish there was a better way to represent boolean values but I didn't find one after some quick testing.)

cuegui/cuegui/HostMonitor.py Outdated Show resolved Hide resolved
@srbhss
Copy link
Contributor Author

srbhss commented Apr 16, 2020

@bcipriano sir
I think now it will work fine, used int() to convert string value to int before passing to bool()

self.__viewHostsSetup() # For view_hosts signal
self.__viewHostsSetup() # For view_hosts signal

if bool(QtGui.qApp.settings.value("AutoRefreshMonitorHost", 1)): # For refresh on launch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line needs to convert to int as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. My mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correction made.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe bool(int(x))) call is redundant, is there any benefit over simply allowing Python to handle the truthiness check?
for example:
if int(QtGui.qApp.settings.value("AutoRefreshMonitorHost", 1)): ...
has the same effect as
if bool(int(QtGui.qApp.settings.value("AutoRefreshMonitorHost", 1))): ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregdenton sir, you are right. I have used bool() to make the mechanism more clear to understand. It doesn't have any significance as far as working of code is concerned. It could be removed if it is looking bit too heavy-handed.
IMO it is good to store and use bool value for conditional statements.
For example bool value stored below:
self.enableRefresh = bool(int(QtGui.qApp.settings.value("AutoRefreshMonitorHost", 1)))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm a bit torn on this one. The bool() is technically not necessary but it does make it more explicit, which is especially useful in a class-wide variable like in @srbhss's example.

I think I would lean towards keeping the bool cast.

@srbhss
Copy link
Contributor Author

srbhss commented Apr 21, 2020

@bcipriano please check the final update and merge.

Copy link
Collaborator

@bcipriano bcipriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very close and the code is working, there's just one comment to resolve regarding the value that gets stored in the ini file.

@@ -256,6 +260,7 @@ def __refreshToggleCheckBoxSetup(self, layout):

def __refreshToggleCheckBoxHandle(self, state):
self.hostMonitorTree.enableRefresh = bool(state)
QtGui.qApp.settings.setValue("AutoRefreshMonitorHost", int(state))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tested this change, when the checkbox is checked state here is equal to 2, causing me to end up with a config file like this:

[General]
AutoRefreshMonitorHost=2
AutoRefreshMonitorProc=2
LastNotice=1587770087
<cut>

While the code works, I think it's best to ensure only 0 or 1 end up in that settings file as it's less confusing. A 2 would seem to imply that there's more than two options when there aren't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is because our checkbox has check-values 0 for 'False', 1 for 'Null' and 2 for 'True'.
One solution is to pass bool() before int() i.e. int(bool(state))
Other is to change the check-value for states.
Using first solution will solve the problem even if I am wrong about the actual problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcipriano sir, changes done. Ready for review.

@@ -120,6 +124,7 @@ def __refreshToggleCheckBoxSetup(self, layout):

def __refreshToggleCheckBoxHandle(self, state):
self.procMonitorTree.enableRefresh = bool(state)
QtGui.qApp.settings.setValue("AutoRefreshMonitorProc", int(state))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here as above, regarding the integer value of state.

Copy link
Collaborator

@bcipriano bcipriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working great! Thank you!

@bcipriano bcipriano merged commit 4f815a6 into AcademySoftwareFoundation:master Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants