« first day (2123 days earlier)      last day (2835 days later) » 

12:04 AM
howdy folks
anybody has creative naming ideas ? for my power consumption indicator
 
okay
so.. terrible idea. But it just popped in my head.
call it the kill counter. For how many watts your laptop killed.
 
@Serg juicebar
 
(kil a watt)
okay, I'm leaving now...
 
that actually made me lol
 
lol seth
 
12:09 AM
since it's using upower, how about i call it upower-indicator ? or would owners or upower be offended ?
 
'cause u got the powe...r.
nope. nvm.
@Serg highly unlikely.
 
I shall name thee . . . .galvani-indicator . . . in honor of Luigi Galvani
If there's no objection , I shall initialize the git repo then
 
you could name it after yourself and call it serginator
 
spi -- sergs-power-indicator
 
12:59 AM
python... whyy
 
Documentation is public now on Stack Overflow.
 
@NathanOsman do you have a sec?
 
I do now.
Just got in.
Go for it.
 
okay, because python is making me mad
I created a preferences util for my code:
def getPref(chat, key):
    # Get the pref from the loaded file
    if chkPref(chat, key) == False:
        return None
    return prefs[chat][key]

def setPref(chat, key, value):
    # Set a pref exists for the specified chat.
    prefs[chat] = prefs.get(chat,{})
    prefs[chat][key] = value
    savePref()

def chkPref(chat, key):
    prefs[chat] = prefs.get(chat,{})
    if key in prefs[chat].keys():
        return True

    return False

def loadPref():
    global prefs

    with open('config/prefs.json', 'r+') as f:
It honestly works pretty well, except for one important thing.
this is what happens when i call setPref:

{"x": {"a": [15]}, "x": {"a": [23]}}
 
Wait, duplicate keys?
 
1:05 AM
that's what I thought.
 
Mind if I suggest a few improvements and then try to figure out what's happening?
 
yeah ofc
my code sucks so it needs it :D
 
Gimme a few minutes.
@KazWolfe No, there's just a few subtle bugs hiding in there.
 
if you want to see a horrible workaround you should see my command handler.
this is 2.7.10 btw
or whatever the newest 2.7.x is
 
class Prefs:
    """
    Object used for storing preferences.
    """

    def __init__(self):
        self._prefs = {}

    def get(self, chat, key):
        """
        Retrieve the value for the provided key in chat. Return None if the
        key or chat does not exist.
        """
        try:
            return self._prefs[chat][key]
        except KeyError:
            return None

    def set(self, chat, key, value):
        """
        Set the value for the provided key in chat, creating objects as needed.
There, I made a few changes.
First of all, I moved everything into a class.
Global variables are frowned on quite heavily.
Secondly, I simplified the code for retrieving values.
Rather than check for the chat key and then the other key, it's easier to just try to access both of them and then catch an error.
 
1:17 AM
okay, makes sense
 
So to use the class, do something like this:
p = Prefs()
p.set('x', 'a', 12)
p.save()
 
i can't put save in set?
 
Oh, I didn't notice that in your example, sorry.
Just add this to the end of set():
self.save()
That will work fine.
 
alright great. And I can access prefs directly using p?
Like if I need the raw prefs for some reason as opposed to getting the list.
 
I would advise against doing that - it's not really good design. But if you have a good reason, just create a method that acts as an accessor:
def all(self):
    return self._prefs
Then you can do:
p.all()
 
1:20 AM
the reason i had that was:

`for id in prefs.keys()`
 
...to get at the underlying dict.
If you really wanted to be clever, you could implement __getitem__().
That would let you do this:
 
i want it to work but eh
 
p['chat']
You can implement __len__() which would then let you do:
len(p)
There are lots of operators you can overload :D
 
def __len__(self):
return len(self._prefs)?
 
You catch on quick :D
See how intuitive Python is? :)
 
1:24 AM
and...
def __getitem__(self):
return self._prefs
?
 
Almost.
def __getitem__(self, chat):
    return self._prefs.get(chat, {})
 
ah.
let's try this out.
so jsut to be sure.
using that getitem, this if 'x' in p[chat_id] will work?
where x is the pref i want to check existence of
 
@ByteCommander the more I play with upower the more it seems buggy. It reports values that differ from what's in sys class power_supply files by about 7%
Unless they do some other calculation that takes some other things into account
 
@KazWolfe Yes.
 
awesome. now to find and fix another bug :D
 
1:36 AM
it also has weird 2 minute update period unless some event happens. so if you don't touch anything, it will update battery status every 2 minutes.
 
@NathanOsman I cant seem to pull from the prefs
oh, hang on. Do I need to re-load prefs in every file where they're used?
 
What do you mean?
 
I'm calling a pref read from a def.
 
Anything written to the preferences will not show up in other Prefs instances until load() is called.
 
Do I need to re-load the preferences, or would they have already loaded?
 
1:45 AM
When?
 
Inside the def
 
@Serg that Unity launcher colour script is cool
 
def x():
    p = Prefs()
    p.get("123", "name")
i guess i need to load it there too?
 
Oh, you need to explicitly load them with:
p.load()
Or... you could stick this in __init__():
self._load()
 
there isn't a way in python to just load it once and have it be persistent?
 
1:47 AM
...in place of the self._prefs = {} line.
@KazWolfe It is going to persist in that object as long as you have it.
 
@NathanOsman okay, i see. But I mean, I have a "core" file that loads everything for other things to use.
I can't just load prefs once there and have it be available to my sub-scripts?
 
You could.
Just create a single instance of Prefs and pass that along to other scripts.
 
though use of globals?
one of the things with prefs is they need to all have the exact same thing.
 
Well, if you can't pass it around, I guess you'd have to use a global.
Or you could make all the methods in Prefs static.
 
huh. i'll just globalize them. I think it's fine for my use case.
 
1:51 AM
yawn
I sleep too freqently.
 
gah! it's still doing the dupe thing @NathanOsman
 
Can you show me the code setting the values?
 
gimme a sec i gotta sanitize it
 
@NathanOsman how's @GeorgetheDev going?
 
def watch(args):
    chat_id = args['chat_id']
    params = args['params']

    if len(params) != 2:
        bot.sendMessage(chat_id, "Command requires two arguments: [add|remove] <id>. Given " + str(len(params)))
        return None;

    if (params[0].lower() == "add"):
        remove = False
    elif (params[0].lower() == "remove"):
        remove = True
    else:
        bot.sendMessage(chat_id, "Command requires two arguments: [add|remove] <id>.")

    currentWatch = prefs.get(chat_id, "alertList")
 
1:54 AM
guys, when I change the hostname, is there any other file to edit besides /etc/hostname and /etc/hosts?
ubuntu has a bad habit of including the username on the hostname :P
I just changed to the computer
 
@KazWolfe Gimme a few minutes to look it over.
 
$ python scratch_pad.py
  File "scratch_pad.py", line 19
    power-rate = None
SyntaxError: can't assign to operator
why ???
def get_power_info():

    battery_path = None
    battery_info = []
    power-rate = None
    voltage = None
    current = None
what's wrong here ?
 
You can't use a hyphen in a variable name.
Change power-rate to power_rate.
 
oooh
 
it has to be in Prefs().set
but i don't know why it creates instead of overwrites
 
2:13 AM
it's the app's fault
2buntu got hacked?!?
 
It did?
 
@NathanOsman this is really making me dislike python
 
an article I was reading
 
PHRASING
You just scared every admin in this room
 
2:19 AM
@ƎpᴉʇʎXD That was some time ago.
 
And it was just the Redis cache.
 
No user data was leaked. As far as we know.
 
oh
I heard about the new bot George the dev
brilliant
 
2:20 AM
yeah @NathanOsman, this makes absolutely zero sense.
it should be working, but something's preventing it, which is really confusing.
 
@KazWolfe What does?
Oh.
I'm looking at it now.
 
the duplicate entries
 
Anybody would like to provide an icon for the power indicator im working on ?
@Zacharee1 doesn't seem to be around
 
Donald Trump: 'I humbly and gratefully accept your nomination for the presidency of the United States' http://www.breakingnews.com/t/RYZ
Barf.
 
Trump is anything but humble , lol
 
2:23 AM
cough cough
ewwww
 
@NathanOsman, I look forward to the day I'll completely understand that post (from the redit hacker) :p
 
It took me a few minutes when I first read it :D
 
I would rather do the liquid nitrogen bucket chellinge rather than have trump be president
I am a pencil. I can swim in it.
 
Is there a way to shut the PyGIWarning up ?
/home/xieerqi/GIT_REPOS/lks-indicator.py:39: PyGIWarning: AppIndicator3 was imported without specifying a version first. Use gi.require_version('AppIndicator3', '0.1') before import to ensure that the right version gets loaded.
  from gi.repository import AppIndicator3  as appindicator
I don't care about specific version since my code is not version specific
 
2:26 AM
GTK+ is the king of useless warnings.
 
@NathanOsman Figured it out
The thing that gives me IDs are inconsistent. So I changed the thing to convert everything to str before storing it
here's another interesting one, nathan
though actually hang on
 
@KazWolfe Ah, glad you figured it out.
 
@NathanOsman got my other problem sovled too
everything works
 
\o/
Yay, supper time.
 
2:39 AM
\o/
 
2:51 AM
is it time for us to do something about this stackoverflow.com/documentation/ubuntu
 
Sure.
I can approve edits.
 
mnn/.nojp
 
@NathanOsman I know, but a lot of users who have no clue about python get freaked out when they see it. Any way to shut it up ?
 
I haven't figured it out yet myself.
So folks... stable distro... are we talking CentOS, Debian stable, or BSD?
Recommendations are welcome. I'll be running Docker on it if that helps.
 
CentOS . . . . I don't believe in Debian's stability
 
3:03 AM
Yeah, I was leaning that way.
 
I need to learn gimp
 
O_o
You haven't used the Gimp?
 
Since I'm making more and more apps and indicators, I'll need icons for them
 
@NathanOsman I have used it ,but just to crop something out, or bucket fill. Can't call it high level of skill really
 
3:05 AM
You would be better off using Inkscape for icons.
Gimp is more for image editing.
 
so @NathanOsman, problem.
 
used InkScape years ago on Windoz . . . will need to learn from scratch , since i don't remember anything
 
actually hang on no sorry
 
3:22 AM
@ByteCommander power-flow-indicator is up on git. Will need to make an icon . So far it only outputs watts. I will add argsparse soon to include amps. I already have a few methods for that
$ python power-flow-indicator
  File "power-flow-indicator", line 160
    args = parser.parse_args()
       ^
SyntaxError: invalid syntax
I took this syntax from official documentation , what do you mean it's invalid ?
oh . .. . open bracket
 
?
what comes before this line
 
3:38 AM
 parser.add_argument("--amps", help="display output in milliamps",action="store_true" )
this line but it was missing closing paren
Hmmm , how do i pass args to a class ?
got it
git push!
 
4:03 AM
gaaaah , i still need an icon
 
4:46 AM
@CodeX glad you like my unity launcher color script by the way :)
So apparently THC , which is chemical in marijuana, has been found in oil well of one Colorado town. Apparently somebody tampered with oil well there
 
5:03 AM
> The user interface of your app is not consistent with the OS X Human Interface Guidelines. Specifically:
>
> We found the app does not use the standard "Quit" menu name for quitting apps, which may lead to user confusion.
Okay, Apple. Fine.
Even though you approved the app last time. I'll fix it.
(Gotta love their inconsistency.)
 
or screw apple? ;)
looks like the export license wasn't the limiting factor
$ lsb_release -d
Description:	Ubuntu 16.04.1 LTS
first point release hype
 
> The application has been set to the minimum OS to be "10.7.0", it should be "10.7"
I guess 10.7.0 != 10.7
Man, they're picky.
 
apple?
 
Yes.
 
iFacePalm
4
 
5:21 AM
iSafariProof
 
Mate doesn't like my icon
 
that looks... interesting
 
it looks less . . . wide . . .in Unity , but Mate hates it
 
Question : the applet/indicator we use in unity ... can it be used in other DE's too ?
 
5:29 AM
Most DEs support app indicators.
 
@CodeX Mostly yes, but there is a big catch. What I have learned so far is that there's two toolkits , appindicator and AppIndicator3 . If appindicator is for gtk2, AppIndicator3 is for Gtk3. Right now the popular DEs support Gtk3, but may or may not support Gtk2. That's why I rewrote my indicator in AppIndicator3. It works in Mate and others. Gnome is a bit special ,because it needs extension to make indicators work properly
 
[ SmokeDetector ] URL-only title, link following arrow in body, pattern-matching website in body, pattern-matching website in title: platinumcleanserinfo.com/t-90-xplode/ by hefuzepaizeo on askubuntu.com
 
I thought not every DE supports indicator because when I installed whatsie on gnome I saw no indicator .. (and yes there is an extension for indicator I later discovered)
oops I should have read your comment before reply xD
replying*
 
:)
 
^creepy smiley face dude
 
5:40 AM
( :
 
() ;
 
so thinking about indicators... what about... cpu temp? weather? (in case of being in the basement and too lazy to check curl wttr.in)? swap usage? any good?
 
I like this todo list indicator
 
all of those already exist :)
 
5:43 AM
psensor for temperature
Gaaaah, OP is killing me . . . I keep editing the script, it works on my machine, but he gets errors
 
haha thanks @CodeX I like their examples, and I need that one! It's a shame it's so ugly (the to-do-list one)
 
@Serg that is a lot of comments on an answer
 
I don't want anything ugly on my desktop...
where a lot of comments?
 
there is a good looking to do list extension but for gnome
 
@terdon or @Seth , need comments moved to chat please askubuntu.com/a/800885/295286
 
My computer ;)
facepalmoil
 
im watching Shogun mini series . . . .problem is that it's in spanish . . .and I don't know spanish
 
so first learn spanish and then watch the movie Lol
 
5:54 AM
nah , i'll watch first, then learn
Can anyone help me test this askubuntu.com/questions/800875/…
 
[ SmokeDetector ] Bad keyword in body, link at end of body, pattern-matching website in body: Where to buy Kerave Hair product in north america? by russohazel on askubuntu.com
 
I don't know what's the issue. IT's supposed to properly get battery path , but in OP's case it doesn't
 
ask OP to pay for canonical support
 
nah, i can't ask for money, especially on SE
 
any use for me to test it in MATE?
 
5:57 AM
python battery_notify.py 70
battery_notify.py:1: PyGIWarning: Notify was imported without specifying a version first. Use gi.require_version('Notify', '0.7') before import to ensure that the right version gets loaded.
from gi.repository import Notify
Traceback (most recent call last):
File "battery_notify.py", line 6, in <module>
import dbus
ImportError: No module named dbus
 
hmmm
 
wut, no dbus?
 
[ SmokeDetector ] Bad keyword in title, link at end of body, link following arrow in body, pattern-matching website in body: Muscle Xtx Another problem with too much information? by williamlmeija on askubuntu.com
 
@Zanna em . . . check if you have python-dbus installed first. @CodeX turns out doesn't have it
The use is basically alternative battery monitor . . . .
 
yeah I have it
 
6:01 AM
@Serg i believe python3-dbus is installed by default but not python-dbus
 
'python-dbus is already the newest version'
 
$ apt list python-dbus python3-dbus
Listing... Done
python-dbus/xenial 1.2.0-3 amd64
python3-dbus/xenial,now 1.2.0-3 amd64 [installed,automatic]
 
apt list python-dbus python3-dbus
Listing... Done
python-dbus/xenial 1.2.0-3 amd64
python3-dbus/xenial,now 1.2.0-3 amd64 [installed,automatic]
 
different for me - python-dbus installed but not python3-dbus
 
looks like serg needs to write py2/3-compatible code ;)
 
6:06 AM
@_@
 
poor Serg...
script is running, battery is charging...
 
how about upower -e ?
what does this tell to you guys ?
 
zanna@monster:~$ upower -e
/org/freedesktop/UPower/devices/battery_BATC
/org/freedesktop/UPower/devices/line_power_ADP1
/org/freedesktop/UPower/devices/DisplayDevice
 
actually from your gist, your code looks ok on python 2 and 3. so maybe @CodeX should run your script with python3 and see what happens
 
~/Scripts$ upower -e
/org/freedesktop/UPower/devices/line_power_ACAD
/org/freedesktop/UPower/devices/battery_BAT1
/org/freedesktop/UPower/devices/DisplayDevice
 
6:08 AM
$ upower -e
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/battery_BAT0
/org/freedesktop/UPower/devices/DisplayDevice
 
~/Scripts$ python3 battery_notify.py 70
battery_notify.py:1: PyGIWarning: Notify was imported without specifying a version first. Use gi.require_version('Notify', '0.7') before import to ensure that the right version gets loaded.
from gi.repository import Notify
should I be seeing a notification ? battery is 59%
 
Yes, you should be
:/
 
I dont see anything
 
dammit . . .
something isn't right
 
I don't see anything either
 
6:12 AM
I guess ill have to rewrite everything
 
I see a twelve foot monster that looks like a combination of Tux and Linus Torvalds. Is that supposed to happen?
 
O_O wut ???
 
wut?
 
Must be these nachos.
:D
 
6:14 AM
i don't think those were just nachos...
 
(If anyone wonders whether I am kidding or not, bear in mind that I don't even like nachos.)
 
i would love a burrito right now
 
@serg is this on your git ?
 
I dont know anything about python .. but I dont see any error now after adding

import gi
gi.require_version('Notify', '0.7')
 
@Videonauth it's a gist on git . If you mean the python code that is failing.
 
6:18 AM
ye that i was talking about
 
@CodeX that warning was unimportant
 
@serg oh
 
many many programms/scripts within ubuntu produce this warning :p
 
My script is probably buggy somewhere . . . I'll need to re-work it
 
6:20 AM
what hapens and what exactly is it supposed to do ?
 
It's supposed to run like so
python bat_monitor.py 30
At 30 it should start sending notifications
 
supposedly on 2.7 ?
or on 3.5 ?
 
shouldn't be python version specific
 
^well it depends what version of python bindings for dbus you have
 
I AM AN IDIOTTA
or not . . .wait . . .i misread my own code
nah, still am
 
6:24 AM
well on py2.7 it shows me nothing
only the warning
but well i have no battery on my main machine, let me get a make a cat and feed the coffee and then i pull out the laptop
 
@Videonauth thanks . I am suspecting the way I wrote notification function is wrong, because the rest works alright. Also . . . check if you can run notify-send "hello world" in bash . I think my script completely blocked notify-osd
 
on main machine it shows the notification when the script runs
mhmmm weird
on my laptop it produces this output: No warning about gi version but two times `from: can't read /var/mail/gi.repository
i started it with 97 % and when i try to kill the script with ctrl-c it throws an error in line 9
 
6:39 AM
i need to learn more about notifications i guess
 
aww new version of pycharm is out
 
meanwhile, I'm still using vim haha
 
line 41 locale variable might be referenced before assignment
proxy = bus.get_object(obj, path)
and pep 8 considers removing one blankline at the end of file
to be pep8 compliant
unresolved reference Notify
 
I'll deal with pep8 later. i need to have working code first
 
for line 1
 
6:46 AM
line 1?
line 1 is shebang
 
and unused import statement in line 2
well then line two it hadnt had a shebang on the gist
 
odd
 
@JacobVlijm let me get my rep 1st and then you can dupe it >:-D
 
ok, so my notify function is totally wrong it seems
 
6:52 AM
but how is it unresolved ? i use Notify multiple times there
 
seems there is no Function called Notify in gi.repository
just tried to retype the line and it didnt even give me the option to autocomplete
 
@Videonauth does it happen with other gi.repository classes ? ( that's class, not a function )
 
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
>>> import gi.repository
>>> dir(gi.repository)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'absolute_import']
 
@Videonauth do pydoc gi.repository.Notify
 
import gi.repository.Notify as Notify
 

« first day (2123 days earlier)      last day (2835 days later) »