Page 1 of 1

SamsungTools — FORKED

Posted: 12 Jul 2013, 16:38
by mrDoctorWho
Hello all, hello developers.

I created a simple fork for SamsungTools program.

First i cleaned code. It was not good and still its.
Next i added support for "battery life time extender" as developers and users wanted.

I hope you enjoy it, and hope, that developers accept me in their "team", because i want to help developing it.

Source code attached here, maybe i'll cheate .deb's.

Best regards, mrDoctorWho.

Re: SamsungTools — FORKED

Posted: 12 Jul 2013, 17:18
by mrDoctorWho
As i said, i created .deb package.
Get it here: http://simpleapps.ru/samsung-tools_2.2_all.deb (Voria forum doesn't accept .deb)

Re: SamsungTools — FORKED

Posted: 15 Jul 2013, 12:06
by voria
Hi,
first of all, thanks for your interest in "Samsung Tools" project, which is rather slack at the moment (along with the whole project "Linux On My Samsung"). The main reason is that I've lost interest, I'm starting to dislike Samsung products, and it just does not feel right to waste my time to fix their products.

The "Samsung Tools" code is far from perfect, it was written in a fast way to make it usable in short times. In fact, the first thing in my TODO list was code refactoring (which I never did for the said lack of interest).

That said, I was looking at your changes, they seem good to me except for some "simplifications" you did which in result make the code harder to read, and I prefer readability over the syntesis.

For example, you changed this:

Code: Select all

with open(SL_PATH_BACKLIGHT, 'r') as file:
	status = int(file.read(1))
	if status == 0:
		return True
	else:
		return False
with:

Code: Select all

return not bool(int(rFile(SL_PATH_BACKLIGHT)[0]))
I don't like it.

If you provide me with a proper patch that I can apply to the bzr branch, I would be happy to apply it.

Greetings ;)

Re: SamsungTools — FORKED

Posted: 15 Jul 2013, 12:13
by voria
Why did you report this thread as spam?

Re: SamsungTools — FORKED

Posted: 15 Jul 2013, 12:16
by mrDoctorWho
voRia wrote: For example, you changed this:

Code: Select all

with open(SL_PATH_BACKLIGHT, 'r') as file:
	status = int(file.read(1))
	if status == 0:
		return True
	else:
		return False
with:

Code: Select all

return not bool(int(rFile(SL_PATH_BACKLIGHT)[0]))
I don't like it.
Hello voRia! I just cleaned code. In your code, CPU doing excess operation. Python accepts 0/1 as bool code, why don't use this?

Re: SamsungTools — FORKED

Posted: 15 Jul 2013, 12:24
by mrDoctorWho
voRia, I just wanted to draw your attention to this post. I tried many times to contact some developers of some python projects. They just ignores any additions.
After all. Can you accept my addition request to your jabberID? We can talk in it about code parts that you don't like and take a solution

Re: SamsungTools — FORKED

Posted: 15 Jul 2013, 12:33
by voria
mrDoctorWho wrote: Hello voRia! I just cleaned code. In your code, CPU doing excess operation. Python accepts 0/1 as bool code, why don't use this?
For the sake of clarity.
mrDoctorWho wrote:voRia, I just wanted to draw your attention to this post. I tried many times to contact some developers of some python projects. They just ignores any additions.
Ok, but I already got your private email and the bug report you filed on Launchpad. ;)
mrDoctorWho wrote: After all. Can you accept my addition request to your jabberID? We can talk here about code parts that you don't like and take a solution
I don't use jabber anymore, I completely moved to my google account (GTalk/Hangouts).
You can contact me there or by email.

Re: SamsungTools — FORKED

Posted: 15 Jul 2013, 12:42
by mrDoctorWho
voRia wrote: For the sake of clarity.
If user look at code, he should know python or basis of programming. Python as original is easy to understand. Making program slower for better reading is a bad tone. Need a average of it. All web-developers doing optimization of their code: they using 1/0 instread of true/false in js. they using obfuscation and something else.
voRia wrote: I don't use jabber anymore, I completely moved to my google account (GTalk/Hangouts).
You can contact me there or by email.
So, accept GTalk addition. I using both: jabber & gtalk. GTalk is almost jabber, it based on xmpp protocol.

Re: SamsungTools — FORKED

Posted: 16 Jul 2013, 14:06
by Popup
[ Aside on programming style ]
mrDoctorWho wrote: Making program slower for better reading is a bad tone. Need a average of it. All web-developers doing optimization of their code: they using 1/0 instread of true/false in js.
While I don't use python myself, I must say that I object to that statement.

As Knuth himself said1:
Donald Knuth wrote:We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil
Your code does indeed have the advantage of making the code more compact, which would have been worthwhile in the bad old days of 25-line terminals. Today we can all afford to see 100+lines of code at a time, and compact code is no longer a necessary boon. (And if you have a clever enough editor it can probably be folded away.)

At the same time - don't make any premature pronouncements on performance without running the code through a profiler! Modern compilers are pretty clever at optimization, and I'm pretty sure that using '1/0' instead of 'true/false' won't result in different machine code.

1Apparently I can't post links - I found that quote here: http://en.wikipedia.org/wiki/Optimizati ... ted268_2-0


[ / Aside ]

Re: SamsungTools — FORKED

Posted: 16 Jul 2013, 14:29
by mrDoctorWho
It's a part of code, that i replaced in samsung-tools:

Code: Select all

if os.path.exists(spam):
    return True
else:
    return False
That's code is incorrect. Why? Just its extra (not needed) operation. We can do that and it will be correct:

Code: Select all

return os.path.exists(spam)
Its not just simple, it's correct. And i'm sure that PEP8 accept it. Did you read "Zen of Python"?
Zen of Python #3 wrote: Simple is better than complex.

Re: SamsungTools — FORKED

Posted: 16 Jul 2013, 14:40
by voria
@mrDoctorWho:
I agree with you on your last example, it's just a banal error from my part, writing code too fast without taking a proper look at it afterward. There was other code in that if-else block which I removed later and I forgot to remove the if-else block itself. ;)

Yet, this example does not prove your point, the previous code snippets posted are not errors, they are good and perfectly readable as they are.
Also, I don't think optimization is that much important here: samsung-tools does a very simple job and it's not crucial to be as fast as possible. On the other hand, code readability allows me (and you ;)) to easily work on the code.