You are not logged in.

#151 2011-11-20 14:11:16

jrenong
Member
Registered: 2011-11-20
Posts: 4

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

hi i'm new in arch so hello everybody and i have a little problem with paconky.py i didn't modify the paconky.py and my conkyrc says " '/etc/pacman.conf',unrecognized option" and i'm a newbie in python so i don't know how to fix it

thanx

ps: i'm french so my english is possibly bad sorry

Offline

#152 2011-11-24 19:13:32

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

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

Hi,

I can't reproduce the error. Run the paconky command in a terminal and post the output. If you see this

${color1}${hr}
${color1}[${color2}core${color1}]                    ${color3}6 new packages
bash                           4.2.020-1

then paconky.py is working correctly.

The error may be in your conky configuration file. Post that too.


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

Offline

#153 2011-11-25 06:01:50

jrenong
Member
Registered: 2011-11-20
Posts: 4

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

hi,
in my terminal i see this

$ .conky/paconky.py /tmp/paconky
('/etc/pacman.conf', 'unrecognized option', 'ILoveCandy')
Traceback (most recent call last):
  File ".conky/paconky.py", line 238, in <module>
    main(sys.argv[1])
  File ".conky/paconky.py", line 196, in main
    action_sync.main(('-b', tmp_db_path, '-y'))
  File "/usr/lib/python3.2/site-packages/pycman/action_sync.py", line 229, in main
    ret = do_refresh(args)
  File "/usr/lib/python3.2/site-packages/pycman/action_sync.py", line 42, in do_refresh
    t = transaction.init_from_options(options)
  File "/usr/lib/python3.2/site-packages/pycman/transaction.py", line 112, in init_from_options
    progress_callback = cb_progress)
alpm.error: transaction could not be initialized, pm_errno 10 (unable to lock database)
Exception ValueError: 'I/O operation on closed file.' in <_io.TextIOWrapper name='/dev/null' mode='w' encoding='UTF-8'> ignored

and when i run just .conky/paconky it says : no temporary path given


do you have an idea ?

Offline

#154 2011-11-25 23:05:38

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

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

You seem to have a line /etc/pacman.conf that begins with 'ILoveCandy'. That isn't a valid option and pyalpm therefore doesn't recognize it.

Fix pacman.conf and everything else should work.


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

Offline

#155 2011-11-26 07:25:43

jrenong
Member
Registered: 2011-11-20
Posts: 4

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

heuu Idon't know to say but i can't find it and if you don't put this line in the original script i probably don't have it

my paconky.py :

#!/usr/bin/env python3

# Author: Xyne

"""Display information about upgradable packages in Conky.

This script is meant to be customized. The default is just an example.

USAGE
  paconky.py /temporary/database/path

EXAMPLES
  A static path:

      paconky.py ~/.cache/pacman

  Using tmpfs:

      paconky.py /dev/shm/pacman

  If the XDG_CACHE_HOME variable is set with 1 path:

      paconky.py "$XDG_CACHE_HOME"/pacman

  ... or with multiple paths:

      paconky.py "$(echo $XDG_CACHE_HOME | cut -d':' -f1)"/pacman


DEPENDENCIES
  * pyalpm
  * python3-aur


EXAMPLE CONKY CONFIGURATION FILE

  alignment top_left
  gap_x 5
  gap_y 0
  maximum_width 200
  minimum_size 200,1
  own_window yes
  own_window_transparent yes
  own_window_type override
  own_window_hints below

  update_interval 3600
  total_run_times 0
  double_buffer yes

  use_xft yes
  xftfont lime:pixelsize=10
  xftalpha 0.9

  default_color ff0000
  default_outline_color black
  default_shade_color black

  uppercase no
  override_utf8_locale no

  text_buffer_size 4096

  color1 444444
  color2 cccccc
  color3 777777


  TEXT
  ${execp /path/to/paconky.py /tmp/paconky}



"""

import AUR
import pyalpm
import os
import sys

from collections import OrderedDict
from pycman import config, action_sync



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.

  """

  # Necessary because of the buggy way conky handles alignr.
  width = 40


  # 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 "%%".
  header = '${color1}${hr}\n${color1}[${color2}%s${color1}]%s${color3}%s'
  one = '1 new package'
  many = '%d new packages'
  line = '\n%s%s%s'
  footer = '\n${color1}${hr}\n${voffset 10}'

  # Nothing to upgrade.
  if not (upgradable_sync or upgradable_aur):
    hdr = 'local packages'
    msg = 'up-to-date'
    # -2 for brackets
    spacer = ' ' * (width - len(hdr) - len(msg) - 2)
    print(header % (hdr,spacer,msg) + footer);

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

      # -2 for brackets.
      spacer = ' ' * (width - len(hdr) - len(msg) - 2)
      print(header % (hdr,spacer,msg), end='');

      v = sorted(v, key=lambda x: x[0].name)
      for local, sync in v:
        name, version = local.name, sync.version
        spacer = ' ' * (width - len(name) - len(version))
        print(line % (name, spacer, version), end='')

      print(footer)


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

      # -2 for brackets.
      spacer = ' ' * (width - len(hdr) - len(msg) - 2)
      print(header % (hdr,spacer,msg), end='');

      upgradable_aur.sort(key=lambda x: x[0].name)
      for local, aur in upgradable_aur:
        name, version = local.name, aur['Version']
        spacer = ' ' * (width - len(name) - len(version))
        print(line % (name, spacer, version), end='')

      print(footer)




def main(tmp_db_path):
  # 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')
  db_path = conf.options['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.
    os.rename(tmp_local_db_path, tmp_local_db_path + '.old')
    os.symlink(local_db_path, tmp_local_db_path)


  # Redirect the stdout messages download messages to stderr.
  with open(os.devnull, 'w') as f:
    sys.stdout = f
    action_sync.main(('-b', tmp_db_path, '-y'))
    sys.stdout = sys.__stdout__

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

  syncdbs = pyalpm.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(threads=10)
    aur_pkgs = aur.info(foreign.keys())
  except AUR.AURError as e:
    sys.stderr.write(str(e))
    sys.exit(1)

  upgradable_aur = list()
  for aur_pkg in aur_pkgs:
    installed_pkg = foreign[aur_pkg['Name']]
    if pyalpm.vercmp(aur_pkg['Version'], installed_pkg.version) > 0:
      upgradable_aur.append((installed_pkg, aur_pkg))
    installed.remove(installed_pkg)

  display(upgradable, upgradable_aur)



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

an the line in my conkyrc

${execp ~/.conky/paconky.py /tmp/paconky}

maybe that can help you

edit : i have something new i removed /tmp/paconky an now i have this :

$ rm -rf /tmp/paconky

$ .conky/paconky.py /tmp/paconky
('/etc/pacman.conf', 'unrecognized option', 'ILoveCandy')
deleted 26 rows from info
${color1}${hr}
${color1}[${color2}archlinuxfr${color1}]              ${color3}1 new package
volumeicon                       0.4.5-1
${color1}${hr}
${voffset 10}
${color1}${hr}
${color1}[${color2}extra${color1}]                   ${color3}3 new packages
lame                            3.99.2-1
libburn                          1.1.8-1
shared-desktop-ontologies        0.8.1-1
${color1}${hr}
${voffset 10}
 

i still have Ilove candy but now i can see update and  in my conky to . Do you know why ?

Last edited by jrenong (2011-11-26 07:40:19)

Offline

#156 2011-11-27 14:18:44

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

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

jrenong wrote:

i still have Ilove candy but now i can see update and  in my conky to . Do you know why ?

Yep. The problem was that the database lock was still in the directory. I just saw the ILoveCandy message and assumed that was the cause. If I had read to the end of the error message I would have seen that it was complaining about the lock. I was in a rush, sorry.

Paconky.py was probably killed while updating so it left the lock. If that happens again, you can always remove the lock file (db.lck) or the entire /tmp/paconky directory to fix it.

When I have some time, I'll update the script to either display a message about the lock or remove it directly.

Last edited by Xyne (2011-11-27 14:28:46)


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

Offline

#157 2011-11-28 07:56:54

jrenong
Member
Registered: 2011-11-20
Posts: 4

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

ok thanx a lot xyne
I'll wait your update for the line but now it works

But I have a little problem
1) In the image in page one the version are aligne right but in mine it's not it's like center but not really
2) I want to know if you can put the size of each package an total size by type (extra, aur, etc) it's not really usefull but it could be nice if I can have it

thanx

Last edited by jrenong (2011-12-17 09:36:15)

Offline

#158 2011-12-01 21:56:28

zero_one
Member
Registered: 2010-07-07
Posts: 104

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

Anyone know how to fix the hokey displayin paconky.py to something like ${alignr -10}? I've tried a few different ways with no joy. they display by pixel space.

Offline

#159 2011-12-23 20:23:14

guotsuan
Member
Registered: 2011-12-23
Posts: 4

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

I updated my pacman to version 4.0.1. It seems that the paconky is broken due to the new version of pyalpm that came with pacman.
It gave errors:

Traceback (most recent call last):
  File "./paconky.py", line 240, in <module>
    main(sys.argv[1])
  File "./paconky.py", line 201, in main
    installed = set(p for p in pyalpm.get_localdb().pkgcache)
AttributeError: 'module' object has no attribute 'get_localdb'

Offline

#160 2011-12-30 08:56:56

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

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

@jrenong
1) I would have to see the output to know what's going on.
2) The pyalpm backend has full access to everything in the pacman database, so that's possible. It shouldn't be too difficult either if you know a bit of Python. When I get some time I might try to make paconky more customizable via a simplified formatting option, but ultimately it's easier to just let people modify the script directly.

@zero_one
I don't understand the question.

@guotsuan
If it's still broken when the new pyalpm gets out of testing then I will fix it. I would rather keep it working with the current release. I use it myself so I will notice if it breaks.


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

Offline

#161 2012-01-07 03:56:16

damacas
Member
From: Ontario, Canada
Registered: 2011-05-27
Posts: 50

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

Hi,

When I run paconky from the command line, it seems to return the appropriate results, however, from conky I get:

Traceback (most recent call last):
  File "/home/jeff/.paconky/paconky.py", line 240, in <module>
    main(sys.argv[1])
  File "/home/jeff/.paconky/paconky.py", line 198, in main
    action_sync.main(('-b', tmp_db_path, '-y'))
  File "/usr/lib/python3.2/site-packages/pycman/action_sync.py", line 229, in main
    ret = do_refresh(args)
  File "/usr/lib/python3.2/site-packages/pycman/action_sync.py", line 42, in do_refresh
    t = transaction.init_from_options(options)
  File "/usr/lib/python3.2/site-packages/pycman/transaction.py", line 112, in init_from_options
    progress_callback = cb_progress)
alpm.error: transaction could not be initialized, pm_errno 10 (unable to lock database)
Exception ValueError: 'I/O operation on closed file.' in <_io.TextIOWrapper name='/dev/null' mode='w' encoding='UTF-8'> ignored
Traceback (most recent call last):
  File "/home/jeff/.paconky/paconky

I delete the db.lck file and I can run from the command line again...but not call it from conky.

my call from conky is

${execp /home/jeff/.paconky/paconky.py /home/jeff/.paconky/pacman}

running from the command line I get:

$./paconky.py /home/jeff/.paconky/pacman
deleted 39 rows from info
${color1}${hr}
${color1}[${color2}extra${color1}]                    ${color3}1 new package
conky                 1.8.2git20111107-1
${color1}${hr}
${voffset 10}

Any ideas?

Offline

#162 2012-01-10 02:29:03

damacas
Member
From: Ontario, Canada
Registered: 2011-05-27
Posts: 50

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

It would seem that the following works properly now.

${execpi 3600 paconky /home/jeff/.paconky/pacman}

Offline

#163 2012-01-17 09:06:06

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

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

Xyne, pacman 4 is now in core, please fix paconky to work with it smile

Offline

#164 2012-01-17 15:17:48

zero_one
Member
Registered: 2010-07-07
Posts: 104

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

Here is the output of paconky.py with pacman 4

Traceback (most recent call last):
  File "/usr/bin/paconky.py", line 240, in <module>
    main(sys.argv[1])
  File "/usr/bin/paconky.py", line 201, in main
    installed = set(p for p in pyalpm.get_localdb().pkgcache)
AttributeError: 'module' object has no attribute 'get_localdb'

the new version of pyalpm is still in testing, Looks like we are waiting on pyalpm to update before anything can be done.

Last edited by zero_one (2012-01-17 15:25:17)

Offline

#165 2012-01-18 19:53:50

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

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

I've updated the script to work with pacman 4.0 and pyalpm 0.5.3. Let me know if there are any problems.


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

Offline

#166 2012-01-18 20:20:18

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

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

Where is the download site? I checked both AUR and your website, but I could only see the old version...

Offline

#167 2012-01-19 01:09:53

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

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

The script is linked in the first post of this thread.


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

Offline

#168 2012-01-19 12:37:06

amsri
Member
Registered: 2011-06-17
Posts: 48

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

Xyne wrote:

The script is linked in the first post of this thread.

I am sorry but it is a bit confusing. The link paconky.py refers to to paconky.py udated on 2011-07-01 and not in 2012. Is this the script we need to use.

Offline

#169 2012-01-19 12:44:45

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

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

@ Xyne: Thank you!

amsri wrote:
Xyne wrote:

The script is linked in the first post of this thread.

I am sorry but it is a bit confusing. The link paconky.py refers to to paconky.py udated on 2011-07-01 and not in 2012. Is this the script we need to use.

I also got confused about it, but it is right. It works fine for me.

Offline

#170 2012-01-20 02:19:00

zero_one
Member
Registered: 2010-07-07
Posts: 104

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

Thanks, Xyne. I'll check it out now

Offline

#171 2012-01-21 17:56:21

damacas
Member
From: Ontario, Canada
Registered: 2011-05-27
Posts: 50

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

The updated script seemed to work for a couple of days, and now I get this output:

Traceback (most recent call last):
  File "/usr/bin/paconky", line 242, in <module>
    main(sys.argv[1])
  File "/usr/bin/paconky", line 176, in main
    conf = config.PacmanConfig(conf = '/etc/pacman.conf')
  File "/usr/lib/python3.2/site-packages/pycman/config.py", line 157, in __init__
    self.load_from_file(conf)
  File "/usr/lib/python3.2/site-packages/pycman/config.py", line 162, in load_from_file
    for section, key, value in pacman_conf_enumerator(filename):
  File "/usr/lib/python3.2/site-packages/pycman/config.py", line 84, in pacman_conf_enumerator
    filestack.append(open(path))
IOError: [Errno 13] Permission denied: '/etc/pacman.conf'

In conky it looks ok, but indicates..."up-to-date".  It does seem to pickup the updates from the AUR however,

Offline

#172 2012-01-21 19:12:58

Zom
Member
From: Sweden
Registered: 2007-10-27
Posts: 430

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

damacas wrote:

The updated script seemed to work for a couple of days, and now I get this output:

Traceback (most recent call last):
  File "/usr/bin/paconky", line 242, in <module>
    main(sys.argv[1])
  File "/usr/bin/paconky", line 176, in main
    conf = config.PacmanConfig(conf = '/etc/pacman.conf')
  File "/usr/lib/python3.2/site-packages/pycman/config.py", line 157, in __init__
    self.load_from_file(conf)
  File "/usr/lib/python3.2/site-packages/pycman/config.py", line 162, in load_from_file
    for section, key, value in pacman_conf_enumerator(filename):
  File "/usr/lib/python3.2/site-packages/pycman/config.py", line 84, in pacman_conf_enumerator
    filestack.append(open(path))
IOError: [Errno 13] Permission denied: '/etc/pacman.conf'

In conky it looks ok, but indicates..."up-to-date".  It does seem to pickup the updates from the AUR however,

IOError: [Errno 13] Permission denied: '/etc/pacman.conf'
You sure you have the correct permissions on pacman.conf? smile

Offline

#173 2012-01-21 21:48:34

damacas
Member
From: Ontario, Canada
Registered: 2011-05-27
Posts: 50

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

Zom wrote:

IOError: [Errno 13] Permission denied: '/etc/pacman.conf'
You sure you have the correct permissions on pacman.conf? smile

Yup, that was it thanks.  Apparently I muddled the permissions when merging the pacman.conf with the .pacnew file.

Offline

#174 2012-01-21 22:30:20

damacas
Member
From: Ontario, Canada
Registered: 2011-05-27
Posts: 50

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

Well, I don't get an error any more, but the script doesn't seem to be seeing the updatable packages

$paconky /home/jeff/.paconky/pacman
deleted 40 rows from info
${color1}${hr}
${color1}[${color2}local packages${color1}]              ${color3}up-to-date
${color1}${hr}


$pacman -Syu
Password:
:: Synchronizing package databases...
core is up to date
extra                                           1181.1 KiB  1826K/s 00:01 [##########################################] 100%
community                                       1038.3 KiB  2.10M/s 00:00 [##########################################] 100%
catalyst is up to date
:: Starting full system upgrade...
resolving dependencies...
looking for inter-conflicts...

Targets (1): sdl_image-1.2.12-1

Total Download Size:    0.02 MiB
Total Installed Size:   0.07 MiB
Net Upgrade Size:       0.00 MiB

Proceed with installation? [Y/n]

Anyone else notice this?

Last edited by damacas (2012-01-26 23:00:19)

Offline

#175 2012-01-24 21:36:09

damacas
Member
From: Ontario, Canada
Registered: 2011-05-27
Posts: 50

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

In an effort to troubleshoot this I removed the temporary pacman folder and re-ran:

$paconky /home/jeff/.paconky/pacman
WARNING: database file for 'core' does not exist
WARNING: database file for 'extra' does not exist
WARNING: database file for 'community' does not exist
WARNING: database file for 'catalyst' does not exist
${color1}${hr}
${color1}[${color2}local packages${color1}]              ${color3}up-to-date
${color1}${hr}

any ideas from this?  I really liked this script for the short time I've had it working.

Offline

Board footer

Powered by FluxBB