You are not logged in.

#201 2012-04-06 18:18:45

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

@enifeder
Remove the ~/.scripts/repos.paconky directory and install the latest version of paconky.py.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#202 2012-04-07 04:37:17

enifeder
Member
Registered: 2012-03-21
Posts: 13

Re: Paconky: displays repo and AUR pkg info in conky

Xyne wrote:

@enifeder
Remove the ~/.scripts/repos.paconky directory and install the latest version of paconky.py.

Seems to be doing something now. Although it says 'system is up to date' when it is not?

Offline

#203 2012-04-07 23:53:44

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

Paconky downloads its own copies of the sync database files.
It does that at whatever interval you set in the conkyrc file (which should be about 2 hours).

I'm guessing that you ran "pacman -Sy" and noticed upgradable files.
Paconky doesn't report them because it only checks its own database files.
Those will be updated at the end of the interval.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#204 2012-04-08 02:40:18

enifeder
Member
Registered: 2012-03-21
Posts: 13

Re: Paconky: displays repo and AUR pkg info in conky

Xyne wrote:

Paconky downloads its own copies of the sync database files.
It does that at whatever interval you set in the conkyrc file (which should be about 2 hours).

I'm guessing that you ran "pacman -Sy" and noticed upgradable files.
Paconky doesn't report them because it only checks its own database files.
Those will be updated at the end of the interval.

Yes I just noticed it now works. Thank you for helping me out

Offline

#205 2012-04-08 08:43:09

lemmy999
Member
Registered: 2012-04-08
Posts: 6

Re: Paconky: displays repo and AUR pkg info in conky

Paconky was working nicely but then I tried to modify conky ( adding some stuff for Deadbeef!!) and now paconky don't work no more .

[chris@alpha ~]$ conky -c ~/.conky_paconky
Conky: desktop window (15d) is root window
Conky: window type - normal
Conky: drawing to created window (0x1800001)
Conky: drawing to double buffer
Traceback (most recent call last):
  File "/home/chris/.scripts/paconky.py", line 257, in <module>
    main(sys.argv[1])
  File "/home/chris/.scripts/paconky.py", line 209, in main
    t = transaction.init_from_options(h, args)
  File "/usr/lib/python3.2/site-packages/pycman/transaction.py", line 111, in init_from_options
    allexplicit = (getattr(options, 'mode', None) == pyalpm.PKG_REASON_EXPLICIT))
alpm.error: transaction could not be initialized, pm_errno 10 (unable to lock database)

I checked /tmp/paconky and couldn't see any lock file in there.

Offline

#206 2012-04-08 11:21:54

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

@enifeder
np

@lemmy999
If pyalpm reports that there's a lock file, then there's a lock file. Maybe it was gone by the time you checked.
Are you running multiple instances of paconky or letting something else use the temporary database?

I've updated paconky to catch that error and print the lock file path. Double-check that it really doesn't exist and try running paconky again.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#207 2012-04-08 14:30:52

lemmy999
Member
Registered: 2012-04-08
Posts: 6

Re: Paconky: displays repo and AUR pkg info in conky

I'm away from my main PC ( where the problem is) for a couple of days. From memory I seem to recollect that there were two folders in /tmp/paconky. One contained three subfolders ( core/extra/community IIRC) and the other contained lots of folders ( probably one for each package updated since I installed paconky)

I am only running one instance of paconky.

I'll check when I get home on Tuesday and see if I can find that pesky lock file.

Offline

#208 2012-04-08 17:20:00

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

I recommend that you remove /tmp/paconky. It only contains a symlink to the local database and separate copies of the sync database files. The former is recreated automatically if it's missing and the latter are downloaded as necessary.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#209 2012-04-10 14:49:57

lemmy999
Member
Registered: 2012-04-08
Posts: 6

Re: Paconky: displays repo and AUR pkg info in conky

@Xyne

On reboot today everything was working exactly as it should.

Thanks for your help.

Offline

#210 2012-04-10 18:26:51

Doorbreath
Member
Registered: 2010-06-08
Posts: 20

Re: Paconky: displays repo and AUR pkg info in conky

My mirror syncs at half past the hour, I'd like my this script to update at say 35 mins past the hour so it's pretty much up to date all the time.  I can't figure out a way to do it.  I thought about something like killall -SIGUSR1 conky in cron to force conky to refresh?  Seems a bit too kludgy though...

Offline

#211 2012-04-11 17:40:39

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

@Doorbreath
You could run paconky in a cronjob and dump the output to a file every hour, then just read the file in your conkyrc.
Just make sure that the file exists (and is updated) when you start up the system (e.g. by running cronwhip before launching conky, or by execp'ing a script in conky that creates/refreshes the output file if it doesn't exist/is older than an hour).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#212 2012-05-03 18:42:31

lemmy999
Member
Registered: 2012-04-08
Posts: 6

Re: Paconky: displays repo and AUR pkg info in conky

Decided to re-install Arch with a new /data partition. I am keen to use paconky again because it is so useful. I'm getting the following error when i run it from the terminal

[chris@alpha ~]$ sudo /home/chris/paconky.py /tmp/paconky
Traceback (most recent call last):
  File "/home/chris/paconky.py", line 77, in <module>
    import AUR
ImportError: No module named AUR
[chris@alpha ~]$ 

Last edited by lemmy999 (2012-05-03 18:43:03)

Offline

#213 2012-05-03 19:12:33

forkboy
Member
From: Blackpool, England
Registered: 2005-09-03
Posts: 74

Re: Paconky: displays repo and AUR pkg info in conky

Did you remember to install pyalpm and python3-aur?

Offline

#214 2012-05-04 15:25:35

lemmy999
Member
Registered: 2012-04-08
Posts: 6

Re: Paconky: displays repo and AUR pkg info in conky

Did you remember to install pyalpm and python3-aur?

pyalpm yes, python3-aur errrrr no roll

Thanks

Offline

#215 2012-08-14 03:48:45

defcon
Member
From: Germany, Bruchsal
Registered: 2006-08-16
Posts: 177

Re: Paconky: displays repo and AUR pkg info in conky

Can't find paconky in AUR? o_O


Registed Linux User 608596

Offline

#216 2012-08-24 00:15:53

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

Sorry for the late reply.

The original paconky, which was packaged, has been deprecated. The replacement script is not available in the AUR because it is just a example script that is mean to be hacked by each user. If it were installed as a package, you would need root privileges to edit it and it would be overwritten every time the package was updated.

You can use xacget to get the latest version of paconky whenever you need it. Just install it somewhere on your user's PATH (and edit it as necessary).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#217 2013-04-13 16:47:10

jaredanderson
Member
Registered: 2013-04-06
Posts: 20

Re: Paconky: displays repo and AUR pkg info in conky

Hey man I think this could be a problem with i3-bar or my conkyrc but I thought i would stop here first. When I run conky from the terminal paconky shows the expected output. but when it is piped through the i3bar everything appears as normal except paconky isn't there at all.  here is my conkyrc

 
out_to_x no
own_window no
out_to_console yes
max_text_width 0
background no
cpu_avg_samples 2
update_interval 4.0
uppercase no
total_run_times 0
if_up_strictness address
use_spacer none
override_utf8_locale no

TEXT

[    
    {
	"full_text": " ${scroll 50  ${execpi 3600  ~/.scripts/paconky /tmp/paconky}} " 
    },
    {
        "full_text": "  \
${exec ~/.scripts/spotify-control getArtist} - \
${exec ~/.scripts/spotify-control getTitle} ",
        "color":
            ${if_match "${exec ~/.scripts/spotify-control getStatus}"=="Playing"}"\#00CC00"${else}
                ${if_match "${exec ~/.scripts/spotify-control getStatus}"=="Paused"}"\#FF8000"${else}
                    "\#CC0000"
                ${endif}
            ${endif}
    },
    {
         "full_text": " Gmail ${execpi 300 python ~/.scripts/gmail.py}"  
    },
    {
        "full_text": " ${kernel}"
    },
    {
        "full_text": " CPU: ${cpu cpu0}%",
        "color":
            ${if_match ${cpu cpu0}>90}"\#FF0000"${else}
                ${if_match ${cpu cpu0}<10}"\#00CC00"${else}
                    "\#ffffff"
                ${endif}
            ${endif}
    },
    {
        "full_text": " RAM: ${memperc}%",
        "color":
            ${if_match ${memperc}>90}"\#FF0000"${else}
                ${if_match ${memperc}<10}"\#00CC00"${else}
                    "\#ffffff"
                ${endif}
            ${endif}
    },  
    {
        "full_text": " Vol: ${exec amixer sget 'Master' | grep 'Mono:' | cut -c22-24 | sed '/^$/d'}"
    },
    {
        "full_text": " ${time %a %m/%d/%y} ${time %I:%M %P}"
    }
]

Offline

#218 2013-04-14 16:48:54

jaredanderson
Member
Registered: 2013-04-06
Posts: 20

Re: Paconky: displays repo and AUR pkg info in conky

** you can ignore this it was with my conkyrc i am crazy

Okay I think I figured out the problem. Your Script comes with formatting which doesn't jell when piped to a bar. so basically i need all of the output in one straight line with no formatting. i figured out how to remove some formatting but i haven't figured out how to remove the indents' that is so that each repo isn't on a different line. so the script outputs something like

 core "x" new package xxxxxx
 extra "x" new package xxxxxx etc. 

when i want it to output something like

 core "x" new package xxxxxx extra "x" new package xxxxxx etc. 

here is my paconky thus far

  #!/usr/bin/env python3
# -*- coding: utf8 -*-

# Author: Xyne

"""Display information about upgradable packages in Conky.
"""

import AUR.RPC as AUR
import errno
import glob
import os
import pyalpm
import shutil
import subprocess
import sys
import urllib.error

from collections import OrderedDict
from pycman import config, action_sync, transaction



def display(upgradable_sync, upgradable_aur):
  """Display the output.

  upgradable_sync: An OrderedDict of sync database names and sets of tuples.
  Each tuple consists of the local package and sync package returned by pyalpm.

  upgradable_aur: A list of tuples. Each tuple consists of the local package
  returned by pyalpm and a dictionary object returned from the AUR.
  """

  # To change the output, edit these formatting strings.
  # You can change anything except the number of "%s" in each.
  # If you need to insert a percent sign, use "%%".
  # The header at the top of each repo list.
  header = '%s %s'
  error = 'update check failed'
  zero = 'updated'
  one = '1 new package'
  many = '%d new packages'
  # Text shown instead of repo when everything is up-to-date.
  zero_text = 'local packages'

  # The line showing a package and the available version.
  line = '%s %s'


  # An error occured.
  if upgradable_sync is None or upgradable_aur is None:
    print(header % (zero_text, error)  );

  # Nothing to upgrade.
  elif not (upgradable_sync or upgradable_aur):
    print(header % (zero_text, zero)   );

  else:
    for repo, pkgs in upgradable_sync.items():
      n = len(pkgs)
      if n > 1:
        msg = many % n
      else:
        msg = one

      print(header % (repo,msg), end='');

      pkgs = sorted(pkgs, key=lambda x: x[0].name)
      for local, sync in pkgs:
        name, version = local.name, sync.version
        print(line % (name, version), end='')

      print( )


    if upgradable_aur:
      n = len(upgradable_aur)
      if n > 1:
        msg = many % n
      else:
        msg = one

      print(header % ('AUR',msg), end='');

      upgradable_aur.sort(key=lambda x: x['Name'])
      for pkg in upgradable_aur:
        print(line % (pkg['Name'], pkg['Version']), end='')

      print( )



def main(tmp_db_path, sync_cmd=None):
  # Use a temporary database path to avoid issues caused by synchronizing the
  # sync database without a full system upgrade.

  # See the discussion here:
  #   https://bbs.archlinux.org/viewtopic.php?pid=951285#p951285

  # Basically, if you sync the database and then install packages without first
  # upgrading the system (-y), you can do some damage.


  tmp_db_path = os.path.abspath(tmp_db_path)
#   conf = config.PacmanConfig(conf = '/etc/pacman.conf')
  h = config.init_with_config("/etc/pacman.conf")
  db_path = h.dbpath
  if tmp_db_path == db_path:
    print("temporary path cannot be %s" % db_path)
    sys.exit(1)
  local_db_path = os.path.join(db_path, 'local')
  tmp_local_db_path = os.path.join(tmp_db_path, 'local')

  # Set up the temporary database path
  if not os.path.exists(tmp_db_path):
    os.makedirs(tmp_db_path)
    os.symlink(local_db_path, tmp_local_db_path)
  elif not os.path.islink(tmp_local_db_path):
    # Move instead of unlinking just in case.
    if os.path.exists(tmp_local_db_path):
      sys.stderr.write(
        "warning: expected file or directory at %s\n" % tmp_local_db_path
      )
      i = 1
      backup_path = tmp_local_db_path + ('.%d' % i)
      while os.path.exists(backup_path):
        i += 1
        backup_path = tmp_local_db_path + ('.%d' % i)
      sys.stderr.write("attempting to move to %s\n" % backup_path)
      os.rename(tmp_local_db_path, backup_path)
    os.symlink(local_db_path, tmp_local_db_path)

  # Copy in the existing database files. If a repo is offline when paconky is
  # run then no database will be downloaded. If the databases are not copied
  # first then the output will be inconsistent due to missing information. For
  # example, if the Haskell repo is offline then Haskell packages will appear
  # in the [community] and [AUR] sections of the output.
  tmp_sync_db_path = os.path.join(tmp_db_path, 'sync')
  os.makedirs(tmp_sync_db_path, exist_ok=True)
  sync_db_path = os.path.join(db_path, 'sync')

  for db in glob.iglob(os.path.join(sync_db_path,'*.db')):
    tmp_db = os.path.join(tmp_sync_db_path, os.path.basename(db))
    try:
      mtime = os.path.getmtime(tmp_db)
    except OSError as e:
      if e.errno != errno.ENOENT:
        raise e
      else:
        mtime = 0
    if mtime < os.path.getmtime(db):
      shutil.copy2(db, tmp_db)



  # Sync the temporary database.
  # Support external synchronizers such as parisync.
  if sync_cmd:
    for index, item in enumerate(sync_cmd):
      if item == '%d':
        sync_cmd[index] = tmp_sync_db_path
      elif item == '%r':
        sync_cmd[index] = os.path.dirname(tmp_sync_db_path)
    p = subprocess.Popen(sync_cmd, stdout=subprocess.PIPE)
    e = p.wait()
    if e != 0:
      sys.stderr.write("sync command exited with %d\n" % e)
    # Re-initialize with new databases.
    args = action_sync.parse_options(('-b', tmp_db_path))
    h = config.init_with_config_and_options(args)
  else:
    args = action_sync.parse_options(('-b', tmp_db_path, '-y'))
    h = config.init_with_config_and_options(args)
    sys.stdout = sys.__stderr__
    try:
      t = transaction.init_from_options(h, args)
    except pyalpm.error as e:
      sys.stderr.write('%s\n' % (e,))
      eno = e.args[1]
      if eno == 10:
        lckpath = os.path.join(tmp_db_path, 'db.lck')
        sys.stderr.write('  %s\n' % lckpath)
      sys.exit(1)
    for db in h.get_syncdbs():
      try:
        db.update(False)
      except pyalpm.error as e:
        sys.stderr.write('%s: %s\n' % (db.name, e))
    t.release()
    sys.stdout = sys.__stdout__


  installed = set(p for p in h.get_localdb().pkgcache)
  upgradable = OrderedDict()

  syncdbs = h.get_syncdbs()
  for db in syncdbs:
    # Without "list" the set cannot be altered with "remove" below.
    for pkg in list(installed):
      pkgname = pkg.name
      syncpkg = db.get_pkg(pkgname)
      if syncpkg:
        if pyalpm.vercmp(syncpkg.version, pkg.version) > 0:
          try:
            upgradable[db.name].add((pkg, syncpkg))
          except KeyError:
            upgradable[db.name] = set(((pkg, syncpkg),))
        installed.remove(pkg)

  foreign = dict([(p.name,p) for p in installed])

  try:
    aur = AUR.AUR()
    aur_pkgs = aur.info(foreign.keys())
    upgradable_aur = list()
    for aur_pkg in aur_pkgs:
      try:
        installed_pkg = foreign[aur_pkg['Name']]
      except KeyError:
        upgradable_aur.append(aur_pkg)
        continue
      if pyalpm.vercmp(aur_pkg['Version'], installed_pkg.version) > 0:
        upgradable_aur.append(aur_pkg)
      installed.remove(installed_pkg)
  except AUR.AURError as e:
    sys.stderr.write(str(e))
    sys.exit(1)
  except urllib.error.URLError as e:
    sys.stderr.write(
      'error: failed to retrieve information from the AUR (%s)\n' % e.reason
    )
    upgradable_aur = None
  except TypeError:
    upgradable_aur = None


  display(upgradable, upgradable_aur)



if __name__ == "__main__":
  if sys.argv[1:]:
    main(sys.argv[1], sys.argv[2:])
  else:
    print("no temporary path given")
    sys.exit(1)

anyway if you point me in the right direction, as to what to remove, I could do it myself. I am just not familiar with python yet. Thank you in advance
** you can ignore this it was with my conkyrc i am crazy. anyway i got it to work

Last edited by jaredanderson (2013-04-14 17:22:16)

Offline

#219 2013-10-09 19:49:04

tumas
Member
Registered: 2012-02-08
Posts: 89

Re: Paconky: displays repo and AUR pkg info in conky

Sry for the probably not so difficult question, but how would i tell the "paconky-script" to show me the number of available updates + let's say the first three upgradable packages? If i understand right, paconky will show me all the available updates, which will be a very long list if e.g. kde gets a new update. So it would be great to shorten that list in some way.

Offline

#220 2013-10-10 21:56:08

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

Information about upgradable packages is passed to the display function at the top of the file. That can easily be configured to print out the number of upgrades and a subset of packages instead of the full list.

I don't have time to post an example right now, but I will try to remember to post one this weekend if no one else does before then. It you don't know any Python then you could use this as a reason to learn a little. You really don't need much and you could probably figure it out before I post an example. wink


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#221 2013-10-11 13:26:51

tumas
Member
Registered: 2012-02-08
Posts: 89

Re: Paconky: displays repo and AUR pkg info in conky

I don't know any Python or any other programming language, but i looked around a little bit and tried something; i changed the code to the following:

....
 pkgs = sorted(pkgs, key=lambda x: x[0].name)
      for local, sync in pkgs:
        name, version = local.name, sync.version
        n = len(pkgs)
      if n < 4:
        print(line % (name, version), end='')
      else:
        print('\n${goto 32}Too many Updates')

...

This way it should show me only 4 Updates and if there are more, it should only show the message "Too many Updates". But i am not sure how i would tell it, to always show 4 Updates, even if there are 5 or more available. And the next problem seems to be, that "n < 4" applies to [core] or [extra] individually and not all of them together. My System is almost UpToDate (only 2 Updates available), but if i set this value to n < 2 it still shows me 2 package names (1 from [core] and 1 from [extra])

PS: It was just a try, so please bear with me wink

Last edited by tumas (2013-10-11 13:30:04)

Offline

#222 2013-10-13 16:11:20

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

This will print out the number of upgradable packages followed by a list of up to 3 package. It should hopefully be clear how to modify it further.

def display(upgradable_sync, upgradable_aur):
  """Display the output.

  upgradable_sync: An OrderedDict of sync database names and sets of tuples.
  Each tuple consists of the local package and sync package returned by pyalpm.

  upgradable_aur: A list of tuples. Each tuple consists of the local package
  returned by pyalpm and a dictionary object returned from the AUR.
  """

  # To change the output, edit these formatting strings.
  # You can change anything except the number of "%s" in each.
  # If you need to insert a percent sign, use "%%".
  # The header at the top of each repo list.
  header = '${color1}${hr}\n${color1}[${color2}%s${color1}] ${alignr}${color3}%s'
  error = 'update check failed'
  zero = 'updated'
  one = '1 new package'
  many = '%d new packages'
  # Text shown instead of repo when everything is up-to-date.
  zero_text = 'local packages'

  # The line showing a package and the available version.
  line = '%s ${alignr}%s'

  # The footer at the end of the list.
  footer = '\n${color1}${hr}\n\n'

  # The maximum number of packages to show.
  max_n = 3

  # An error occured.
  if upgradable_sync is None or upgradable_aur is None:
    print('an error occurred');

  else:
    all_pkgs = list()
    for pkgs in upgradable_sync.values():
      for p in pkgs:
        sp = p[1]
        all_pkgs.append((sp.name, sp.version, sp.builddate))
    for p in upgradable_aur:
      sp = p[1]
      all_pkgs.append((sp['Name'], sp['Version'], sp['LastModified']))
    n = len(all_pkgs)

    # Sort by build or last modification time and limit to max_n.
    all_pkgs = sorted(all_pkgs, key=lambda x: x[2])[:max_n]

    # Sort remaining list by name.
    all_pkgs = sorted(all_pkgs, key=lambda x: x[0])

    if n == 0:
      print(zero)
    elif n == 1:
      print(one)
    else:
      print(many % n)
    for name, version, t in all_pkgs:
      print(line % (name, version))

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#223 2014-02-06 18:12:14

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: Paconky: displays repo and AUR pkg info in conky

Since the recent update to conky, pacconky stopped working for me. Displays nothing in conky and this is the output I get when running from a terminal:


Conky: desktop window (c00021) is subwindow of root window (9d)
Conky: window type - dock
Conky: drawing to created window (0x1200002)
Conky: drawing to double buffer
Traceback (most recent call last):
  File "/home/wankel/.scripts/paconky.py", line 311, in <module>
    main(sys.argv[1], sys.argv[2:])
  File "/home/wankel/.scripts/paconky.py", line 305, in main
    display(upgradable, upgradable_aur)
  File "/home/wankel/.scripts/paconky.py", line 140, in display
    sp = p[1]
KeyError: 1

Does paconky need to be updated or does the solution lie somewhere else?

Last edited by wankel (2014-02-06 18:12:50)

Offline

#224 2014-02-06 23:53:41

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,668
Website

Re: Paconky: displays repo and AUR pkg info in conky

My local version which is mirrored on the site and linked in the first post still works. You seem to have modified it as my version does not contain  "sp = p[1]", and the error appears to lie in the modification.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#225 2014-02-12 23:15:16

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: Paconky: displays repo and AUR pkg info in conky

You're right, I'm using the def display function that you posted in post #222 (the one that allows for the actual package names and versions to be listed). In that you'll find the "sp=p[1]" line. Anyways if the original unmodified script still works I'll just use that, thanks.

Offline

Board footer

Powered by FluxBB