summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-05-21 21:13:05 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-05-21 21:13:05 +0200
commitf4368fbfb9fd0de6f1d1625ffddee17b67926c89 (patch)
tree274c6fe882a2f22aa99d0c301fb90a882e379900
parent43509c27dd08219147e4bcdb0897ebb2f5ec22cc (diff)
parentc24b4970e48771a32155cbc79060c76d218fdd85 (diff)
downloadportato-f4368fbfb9fd0de6f1d1625ffddee17b67926c89.tar.gz
portato-f4368fbfb9fd0de6f1d1625ffddee17b67926c89.tar.bz2
portato-f4368fbfb9fd0de6f1d1625ffddee17b67926c89.zip
Merged from trunk
Diffstat (limited to '')
-rw-r--r--_shm/__init__.py0
-rw-r--r--_shm/shm_wrapper.py302
-rw-r--r--_shm/shmmodule.c1409
-rw-r--r--doc/Changelog2
-rw-r--r--doc/TRANSLATORS2
-rw-r--r--icons/pausing.pngbin0 -> 3121 bytes
-rw-r--r--icons/pausing.svg171
-rwxr-xr-xportato.py8
-rw-r--r--portato/backend/portage/system.py18
-rw-r--r--portato/gui/exception_handling.py1
-rw-r--r--portato/gui/templates/AboutWindow.glade4
-rw-r--r--portato/gui/templates/MainWindow.glade194
-rw-r--r--portato/gui/templates/UpdateWindow.glade4
-rw-r--r--portato/gui/utils.py2
-rw-r--r--portato/gui/windows/main.py6
-rw-r--r--portato/plistener.py8
-rw-r--r--portato/plugins/dbus_init.py10
-rw-r--r--setup.py116
18 files changed, 308 insertions, 1949 deletions
diff --git a/_shm/__init__.py b/_shm/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/_shm/__init__.py
+++ /dev/null
diff --git a/_shm/shm_wrapper.py b/_shm/shm_wrapper.py
deleted file mode 100644
index 851f588..0000000
--- a/_shm/shm_wrapper.py
+++ /dev/null
@@ -1,302 +0,0 @@
-# shm_wrapper - A wrapper for the shm module which provides access
-# to System V shared memory and semaphores on *nix systems.
-#
-# Copyright (c) 2007 by Philip Semanchuk
-# Contact info at http://NikitaTheSpider.com/
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-# Python modules
-import random
-import sys
-
-# Third party modules
-import shm
-from shm import error as shmerror
-
-r"""shm_wrapper - A wrapper for the shm module which provides access
-to System V shared memory and semaphores on *nix systems.
-
-The module shm is a Python wrapper around system functions like shmget. This
-module in turn offers higher-level, more Pythonic access to shared memory and
-semaphores.
-
-Full documentation is online at http://NikitaTheSpider.com/python/shm/
-
-"""
-
-def create_memory(size, permissions = 0666, InitCharacter = ' '):
- """ Creates a new shared memory segment. One can destroy it either by calling the
- module-level method remove_memory() or by calling the .remove() method of a handle to
- said memory.
- """
- memory = None
-
- # I create the memory using a randomly-generated key. I keep trying until I find one
- # that works or until I hit an error.
- while not memory:
- key = random.randint(1, sys.maxint - 1)
- try:
- memory = shm.create_memory(key, size, permissions)
- except shmerror, ExtraData:
- if shm.memory_haskey(key):
- # Oops, bad luck, the key exists. I'll try another. I can't call
- # memory_haskey() before calling create_memory() because that would create
- # a race condition where I could verify a key is not used but then another
- # process could call create_memory() with that key before I got a chance to
- # do so.
- pass
- else:
- # Uh-oh, something fundamental is wrong.
- raise shmerror, ExtraData
-
- # Here I implicitly discard the memory handle object returned to me by shm and instead
- # return my own handle to the shared memory segment.
- memory = SharedMemoryHandle(key)
-
- memory.write(InitCharacter[0] * memory.size)
-
- return memory
-
-
-def remove_memory(key):
- # Destroys the shared memory segment. Raises KeyError if the key doesn't exist.
- shm.remove_memory(shm.getshmid(key))
-
-
-class SharedMemoryHandle(object):
- def __init__(self, key):
- self._MemoryHandle = None
-
- # getshmid will raise a KeyError if there's no memory segment with this key.
- shmid = shm.getshmid(key)
- self._MemoryHandle = shm.memory(shmid)
-
-
- def __del__(self):
- if self._MemoryHandle:
- # This will raise an error if the memory has been destroyed.
- try:
- if self._MemoryHandle.attached:
- self._MemoryHandle.detach()
- except shmerror:
- pass
-
-
- def remove(self):
- if self._MemoryHandle:
- if self._MemoryHandle.attached:
- self._MemoryHandle.detach()
-
- shm.remove_memory(self._MemoryHandle.shmid)
- self._MemoryHandle = None
-
-
- def read(self, NumberOfBytes = 0, offset = 0):
- if not self._MemoryHandle.attached:
- self._MemoryHandle.attach()
-
- if not NumberOfBytes:
- NumberOfBytes = self._MemoryHandle.size - offset
-
- return self._MemoryHandle.read(NumberOfBytes, offset)
-
-
- def write(self, s, offset = 0):
- if not self._MemoryHandle.attached:
- self._MemoryHandle.attach()
-
- self._MemoryHandle.write(s, offset)
-
-
- # Properties start here ================================================================
-
- # key
- def __get_key(self): return self._MemoryHandle.key
- def __set_key(self, foo): raise AttributeError
- key = property(__get_key, __set_key)
-
- # size of segment
- def __get_size(self): return self._MemoryHandle.size
- def __set_size(self, foo): raise AttributeError
- size = property(__get_size, __set_size)
-
- # permissions
- def __get_permissions(self): return self._MemoryHandle.perm
- def __set_permissions(self, permissions): self._MemoryHandle.setperm(permissions)
- permissions = property(__get_permissions, __set_permissions)
-
- # The number of processes currently attached to this memory segment.
- def __get_number_attached(self): return self._MemoryHandle.nattch
- def __set_number_attached(self, foo): raise AttributeError
- number_attached = property(__get_number_attached, __set_number_attached)
-
- # segment's uid
- def __get_uid(self): return self._MemoryHandle.uid
- def __set_uid(self, uid): self._MemoryHandle.setuid(uid)
- uid = property(__get_uid, __set_uid)
-
- # segment's gid
- def __get_gid(self): return self._MemoryHandle.gid
- def __set_gid(self, gid): self._MemoryHandle.setgid(gid)
- gid = property(__get_gid, __set_gid)
-
- # Creator uid (read-only)
- def __get_creator_uid(self): return self._MemoryHandle.cuid
- def __set_creator_uid(self, foo): raise AttributeError
- creator_uid = property(__get_creator_uid, __set_creator_uid)
-
- # Creator gid (read-only)
- def __get_creator_gid(self): return self._MemoryHandle.cgid
- def __set_creator_gid(self, foo): raise AttributeError
- creator_gid = property(__get_creator_gid, __set_creator_gid)
-
- # Creator pid (read-only)
- def __get_creator_pid(self): return self._MemoryHandle.cpid
- def __set_creator_pid(self, foo): raise AttributeError
- creator_pid = property(__get_creator_pid, __set_creator_pid)
-
- # pid of last process to operate on this segment (read-only)
- def __get_last_pid(self): return self._MemoryHandle.lpid
- def __set_last_pid(self, foo): raise AttributeError
- last_pid = property(__get_last_pid, __set_last_pid)
-
-
-
-def create_semaphore(InitialValue = 1, permissions = 0666):
- """ Creates a new semaphore. One can destroy it either by calling the
- module-level method remove_semaphore() or by calling the .remove() method of a
- handle to said semaphore.
- """
- semaphore = None
-
- # I create the semaphore using a randomly-generated key. I keep trying until I find one
- # that works or until I hit an error.
- while not semaphore:
- key = random.randint(1, sys.maxint - 1)
- try:
- semaphore = shm.create_semaphore(key, InitialValue, permissions)
- except shmerror, ExtraData:
- if shm.semaphore_haskey(key):
- # Oops, bad luck, the key exists. I'll try another. I can't call
- # memory_haskey() before calling create_semaphore() because that would create
- # a race condition where I could verify a key is not used but then another
- # process could call create_semaphore() with that key before I got a chance to
- # do so.
- pass
- else:
- # Uh-oh, something fundamental is wrong.
- raise ExtraData
-
- # Here I implicitly discard the semaphore object returned to me by shm and instead
- # return my own handle to the semaphore.
- return SemaphoreHandle(key)
-
-
-def remove_semaphore(key):
- # Destroys the semaphore. Raises KeyError if the key doesn't exist.
- shm.remove_semaphore(shm.getsemid(key))
-
-
-class SemaphoreHandle(object):
- def __init__(self, key):
- # getsemid will raise a KeyError if appropriate.
- self._SemaphoreHandle = shm.semaphore(shm.getsemid(key))
-
-
- def remove(self):
- shm.remove_semaphore(self._SemaphoreHandle.semid)
- self._SemaphoreHandle = None
-
-
- def P(self):
- # P = prolaag = probeer te verlagen (try to decrease)
- self._SemaphoreHandle.P()
-
-
- def V(self):
- # V = verhoog (increase)
- self._SemaphoreHandle.V()
-
-
- def Z(self):
- # Z = block until Zee semaphore is Zero
- self._SemaphoreHandle.Z()
-
-
- # Properties start here ================================================================
- def __get_key(self): return self._SemaphoreHandle.key
- def __set_key(self, foo): raise AttributeError
- key = property(__get_key, __set_key)
-
-
- def __get_value(self): return self._SemaphoreHandle.val
- def __set_value(self, value): self._semaphore.setval(value)
- value = property(__get_value, __set_value)
-
-
- def __get_WaitingForZero(self): return self._SemaphoreHandle.zcnt
- def __set_WaitingForZero(self, foo): raise AttributeError
- WaitingForZero = property(__get_WaitingForZero, __set_WaitingForZero)
-
-
- def __get_WaitingForNonZero(self): return self._SemaphoreHandle.ncnt
- def __set_WaitingForNonZero(self, foo): raise AttributeError
- WaitingForNonZero = property(__get_WaitingForNonZero, __set_WaitingForNonZero)
-
-
- def __get_blocking(self): return self._SemaphoreHandle.blocking
- def __set_blocking(self, block): self._SemaphoreHandle.setblocking(block)
- blocking = property(__get_blocking, __set_blocking)
-
-
- def __get_undo(self): raise AttributeError
- def __set_undo(self, undo): self._SemaphoreHandle.setundo(undo)
- undo = property(__get_undo, __set_undo)
-
-
- # segment's uid
- def __get_uid(self): return self._SemaphoreHandle.uid
- def __set_uid(self, uid): self._SemaphoreHandle.setuid(uid)
- uid = property(__get_uid, __set_uid)
-
-
- # segment's gid
- def __get_gid(self): return self._SemaphoreHandle.gid
- def __set_gid(self, gid): self._SemaphoreHandle.setgid(gid)
- gid = property(__get_gid, __set_gid)
-
-
- # Creator uid (read-only)
- def __get_creator_uid(self): return self._SemaphoreHandle.cuid
- def __set_creator_uid(self, foo): raise AttributeError
- creator_uid = property(__get_creator_uid, __set_creator_uid)
-
-
- # Creator gid (read-only)
- def __get_creator_gid(self): return self._SemaphoreHandle.cgid
- def __set_creator_gid(self, foo): raise AttributeError
- creator_gid = property(__get_creator_gid, __set_creator_gid)
-
-
- # Creator pid -- since semaphores have a lot of the same properties as memory
- # objects, one would expect creator PID to be exposed here, but it isn't
- # made available by the system (true AFAICT for BSDs, OS X and Solaris).
-
-
- # pid of last process to operate on this segment (read-only)
- def __get_last_pid(self): return self._SemaphoreHandle.lpid
- def __set_last_pid(self, foo): raise AttributeError
- last_pid = property(__get_last_pid, __set_last_pid)
diff --git a/_shm/shmmodule.c b/_shm/shmmodule.c
deleted file mode 100644
index c214430..0000000
--- a/_shm/shmmodule.c
+++ /dev/null
@@ -1,1409 +0,0 @@
-/****************************************************************************
- *
- * shmmodule.c Copyright 1997, 1998 by INRIA. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY WARRANTIES, EXPRESS OR IMPLIED,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- *
- * IN NO EVENT SHALL THE INRIA OR THE AUTHORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES,
- * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
- * LOSS OF USE, DATA, OR PROFITS OR BUSINESS INTERRUPTION, HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT,
- * INCLUDING NEGLIGENCE OR OTHERWISE, ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ***************************************************************************/
-
-/* Python Shared Memory module
- Written by Vladimir Marangozov
- Adopted by Philip Semanchuk
-
- This module provides an interface to System V shared memory IPC.
-
- Version history:
- - 1.0 (sometime in the 1990s) - Released by Mr. Marangozov
- - 1.1 (Feb 2007) - Released by me, Philip Semanchuk. Fixes a few bugs (including some
- memory leaks) and adds the ability to read the blocking flag on semaphores.
- - 1.1.1 (Mar 2007)- Updated setup.py to handle compile options for Linux users.
- - 1.1.2 (Nov 2007) - Fixed a sprintf() format in repr to handle size_t.
- - 1.1.3 (Nov 2007) - Changed #define of key to _key instead of __key for OS X Leopard.
- Thanks to Bill Hart.
- - 1.1.4 (Jan 2008) - Changed the reference to key in the ipc_perm structure to the
- explicit #define IPC_PERM_KEY_NAME.
- - 1.2 (Jan 2008) - Surrounded semop() calls with Py_BEGIN/END_ALLOW_THREADS for
- thread-friendly code. Patch provided by James Teh (thanks!).
- Fixed some int/long/ulong sloppiness pointed out by kAbY that could cause
- crashes on 64-bit platforms.
-
-
- See http://NikitaTheSpider.com/python/shm/ for more thorough documentation, a more Pythonic
- wrapper, updates, contact info, setup.py, etc.
-
-
- Module interface:
-
- - shm.create_memory(int Key, int Size [,int Perm=0666]) --> object
- - shm.create_semaphore(int Key [,int Value=1 [,int Perm=0666]]) --> object
- - shm.error
- - shm.ftok(string Path, int ProjId) --> int
- - shm.getsemid(int Key) --> int
- - shm.getshmid(int Key) --> int
- - shm.memory(int Shmid) --> object
- - shm.memory_haskey(int Key) --> int
- - shm.remove_memory(int Shmid) --> None
- - shm.remove_semaphore(int Semid) --> None
- - shm.semaphore(int Semid) --> object
- - shm.semaphore_haskey(int Key) --> int
-
- Memory Objects:
-
- + Members:
-
- - m.addr - attachment address in the process address space
- - m.attached - 0|1
- - m.cgid - gid of creator
- - m.cpid - pid of creator
- - m.cuid - uid of creator
- - m.gid - gid of owner
- - m.key - segment key or IPC_PRIVATE (=0)
- - m.lpid - pid of last shmop
- - m.nattch - current # of attached processes
- - m.perm - operation permission
- - m.shmid - shared memory segment id
- - m.size - segment size
- - m.uid - uid of owner
-
- + Methods:
-
- - m.attach([int Addr=0 [,int How=0]]) --> None
- - m.detach() --> None
- - m.read(int Nbytes [,int Offset=0]) --> string
- - m.setgid(int Gid) --> None
- - m.setperm(int Perm) --> None
- - m.setuid(int Uid) --> None
- - m.write(string Data [,int Offset=0]) --> None
-
- Semaphore Objects:
-
- + Members:
-
- - s.cgid - gid of creator
- - s.cuid - uid of creator
- - s.gid - gid of owner
- - s.key - semaphore key or IPC_PRIVATE (=0)
- - s.lpid - pid of last semop
- - s.ncnt - current # of processes waiting for s.val > 0
- - s.perm - operation permission
- - s.semid - semaphore id
- - s.uid - uid of owner
- - s.val - value of the semaphore counter
- - s.zcnt - current # of processes waiting for s.val == 0
- - s.blocking - whether or not the semaphore is in blocking mode
-
- + Methods:
-
- - s.P() --> None - blocks if s.val == 0; decrements s.val
- - s.V() --> None - increments s.val
- - s.Z() --> None - blocks until s.val == 0
- - s.setblocking(0|1) --> None
- - s.setgid(int Gid) --> None
- - s.setperm(int Perm) --> None
- - s.setuid(int Uid) --> None
- - s.setundo(0|1) --> None
- - s.setval(int Value) --> None
-
-*/
-
-/* ------------------------------------------------------------------------- */
-#include "Python.h"
-#include "structmember.h"
-
-/* v1.1 - added */
-#ifdef __FreeBSD__
-#include <machine/param.h> /* for system definition of PAGE_SIZE */
-#endif
-
-#include <sys/types.h>
-#include <sys/ipc.h> /* for system's IPC_xxx definitions */
-#include <sys/shm.h> /* for shmget, shmat, shmdt, shmctl */
-#include <sys/sem.h> /* for semget, semctl, semop */
-
-/* v1.1.4 - The name of this member varies and is sniffed out by setup.py. */
-#if defined(ZERO_UNDERSCORE_KEY)
-#define IPC_PERM_KEY_NAME key
-#elif defined(ONE_UNDERSCORE_KEY)
-#define IPC_PERM_KEY_NAME _key
-#elif defined(TWO_UNDERSCORE_KEY)
-#define IPC_PERM_KEY_NAME __key
-#endif
-
-/*
--- Exception type for errors detected by this module.
-*/
-
-static PyObject *PyShm_Error;
-
-/*
--- Convenience function to raise an error according to errno.
-*/
-
-static PyObject *
-PyShm_Err(void)
-{
- return PyErr_SetFromErrno(PyShm_Error);
-}
-
-/*
--- The object holding a shared memory segment
-*/
-
-typedef struct {
- PyObject_HEAD
- int shmid; /* shared memory id */
- int mode; /* attachment mode */
- void *addr; /* shmseg start address */
- struct shmid_ds ds; /* data structure */
-} PyShmMemoryObject;
-
-staticforward PyTypeObject PyShmMemory_Type;
-
-#define PyShmObj PyShmMemoryObject
-#define PyShmMemory_Check(op) ((op)->ob_type == &PyShmMemory_Type)
-
-/*
--- The object holding a semaphore
-*/
-
-typedef struct {
- PyObject_HEAD
- int semid; /* semaphore id */
- short opflag; /* IPC_NOWAIT, SEM_UNDO */
- struct semid_ds ds; /* data structure */
-} PyShmSemaphoreObject;
-
-#ifndef HAVE_UNION_SEMUN
-union semun {
- int val; /* used for SETVAL only */
- struct semid_ds *buf; /* for IPC_STAT and IPC_SET */
- unsigned short *array; /* used for GETALL and SETALL */
-};
-#endif
-
-typedef union semun semctl_arg;
-
-staticforward PyTypeObject PyShmSemaphore_Type;
-
-#define PyShmSemObj PyShmSemaphoreObject
-#define PyShmSemaphore_Check(op) ((op)->ob_type == &PyShmSemaphore_Type)
-
-/*
--- Internal dictionaries for Python memory and semaphore objects
-*/
-
-static PyObject *shm_dict = NULL;
-static PyObject *sem_dict = NULL;
-
-/************************************************************/
-/* Memory Objects */
-/************************************************************/
-
-/* This is to check the validity of a Python memory object
- (and to refresh its data status structure). Notably, we
- have to check that the real memory segment it points to
- is still in memory and hasn't changed (test its id and
- size). It could be that the segment has been removed and
- created again by someone else with the same key. This is
- fine as far as the segment (1) has the same id and size,
- and (2) is accessible via shmctl. If you have a better
- test, you're welcome :-) */
-
-static int
-check_memory_identity(PyShmObj *o)
-{
- int new_shmid;
- int old_shmid = o->shmid;
- int old_size = o->ds.shm_segsz;
- key_t old_key = o->ds.shm_perm.IPC_PERM_KEY_NAME;
-
- /*
- -- 1. Try to get the segment identified by the old key (if not IPC_PRIVATE)
- -- 2. On failure or on mismatch of the new and the old id -> fail.
- -- 3. Try to refresh the object's status using the new id.
- -- 4. On failure (the segment cannot be accessed) -> fail.
- -- 5. Finaly, compare the old size and the one we got via the new id.
- */
- if (old_key != IPC_PRIVATE) {
- new_shmid = shmget(old_key, 0, 0);
- if (new_shmid != old_shmid)
- return 0;
- }
- else
- new_shmid = old_shmid;
- if ((shmctl(new_shmid, IPC_STAT, &(o->ds)) != -1) &&
- (old_size == o->ds.shm_segsz) &&
- (old_key == o->ds.shm_perm.IPC_PERM_KEY_NAME))
- return 1;
- return 0;
-}
-
-/* Convenience macro for updating the shared memory data status structure */
-
-#define refresh_memory_status(o) \
- if (!check_memory_identity(o)) { \
- PyErr_SetString(PyShm_Error, "can't access shared memory segment"); \
- return NULL; \
- }
-
-/*
--- attach([,address=0 [,how=0]])
-*/
-
-/* Attach the shared memory segment to the process address space */
-
-static PyObject *
-PyShmMemory_attach(PyShmObj *self, PyObject *args)
-{
- long address = 0;
- int mode = 0;
- void *addr, *old_addr;
-
- if (!PyArg_ParseTuple(args, "|li", &address, &mode))
- return NULL;
- refresh_memory_status(self);
- /* return if already attached with the same mode to the same address */
- if ((self->addr != NULL) && (self->mode == mode) &&
- ((address == 0) || (self->addr == (void *)address))) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- /* perform the attach */
- addr = (void *)shmat(self->shmid, (void *)address, mode);
- if (addr == (void *)-1)
- return PyShm_Err();
- old_addr = self->addr;
- self->addr = addr;
- self->mode = mode;
- /* XXX - multiple attachments of the same shared memory segment
- to different locations of the process address space is
- not supported. */
- shmdt(old_addr);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- detach()
-*/
-
-/* Detach the memory object from the process address space */
-
-static PyObject *
-PyShmMemory_detach(PyShmObj *self, PyObject *args)
-{
- if (!PyArg_NoArgs(args))
- return NULL;
- if (self->addr != NULL) {
- refresh_memory_status(self);
- if (shmdt(self->addr) != 0)
- return PyShm_Err();
- self->addr = NULL; /* mark as detached */
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- read(int Nbytes [,int Offset=0]) --> string
-*/
-
-/* Return a string of n bytes peeked from the shared memory segment */
-
-static PyObject *
-PyShmMemory_read(PyShmObj *self, PyObject *args)
-{
- long n;
- long offset = 0;
- char buf[128];
- char *addr;
-
- if (!PyArg_ParseTuple(args, "l|l", &n, &offset))
- return NULL;
- refresh_memory_status(self);
- if (self->addr == NULL) {
- PyErr_SetString(PyShm_Error, "R/W operation on detached memory");
- return NULL;
- }
- if ((unsigned long)self->ds.shm_segsz < (n + offset)) {
- sprintf(buf, "read() argument%s exceed%s upper memory limit",
- offset ? "s" : "", offset ? "" : "s");
- PyErr_SetString(PyShm_Error, buf);
- return NULL;
- }
- addr = (char *)((unsigned long)self->addr + offset);
- return PyString_FromStringAndSize(addr, n);
-}
-
-/*
--- setgid(int Gid)
-*/
-
-static PyObject *
-PyShmMemory_setgid(PyShmObj *self, PyObject *args)
-{
- long newgid, oldgid;
-
- if (!PyArg_ParseTuple(args, "l", &newgid))
- return NULL;
- refresh_memory_status(self);
- oldgid = (long)self->ds.shm_perm.gid;
- self->ds.shm_perm.gid = (gid_t)newgid;
- if (shmctl(self->shmid, IPC_SET, &(self->ds)) == -1) {
- self->ds.shm_perm.gid = (gid_t)oldgid;
- return PyShm_Err();
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setperm(int Perm)
-*/
-
-static PyObject *
-PyShmMemory_setperm(PyShmObj *self, PyObject *args)
-{
- long newmode, oldmode;
-
- if (!PyArg_ParseTuple(args, "l", &newmode))
- return NULL;
- refresh_memory_status(self);
- newmode &= 0777; /* permission bits only */
- oldmode = (mode_t)self->ds.shm_perm.mode;
- self->ds.shm_perm.mode ^= 0777;
- self->ds.shm_perm.mode |= (mode_t)newmode;
- if (shmctl(self->shmid, IPC_SET, &(self->ds)) == -1) {
- self->ds.shm_perm.mode = (mode_t)oldmode;
- return PyShm_Err();
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setuid(int Uid)
-*/
-
-static PyObject *
-PyShmMemory_setuid(PyShmObj *self, PyObject *args)
-{
- long newuid, olduid;
-
- if (!PyArg_ParseTuple(args, "l", &newuid))
- return NULL;
- refresh_memory_status(self);
- olduid = (long)self->ds.shm_perm.uid;
- /* v1.1 - fixed typo that set the group id rather than the user id */
- self->ds.shm_perm.uid = (uid_t)newuid;
- if (shmctl(self->shmid, IPC_SET, &(self->ds)) == -1) {
- self->ds.shm_perm.uid = (uid_t)olduid;
- return PyShm_Err();
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- write(string Data [, int Offset=0])
-*/
-
-/* Write a string to the shared memory segment. */
-
-static PyObject *
-PyShmMemory_write(PyShmObj *self, PyObject *args)
-{
- char *data;
- int n;
- long offset = 0;
- char buf[128];
- char *addr;
-
- if (!PyArg_ParseTuple(args, "s#|l", &data, &n, &offset))
- return NULL;
- refresh_memory_status(self);
- if (self->addr == NULL) {
- PyErr_SetString(PyShm_Error, "R/W operation on detached memory");
- return NULL;
- }
- if (self->mode & SHM_RDONLY) {
- PyErr_SetString(PyShm_Error,
- "can't write on read-only attached memory");
- return NULL;
- }
- if ((unsigned long)self->ds.shm_segsz < (n + offset)) {
- sprintf(buf, "write() argument%s exceed%s upper memory limit",
- offset ? "s" : "", offset ? "" : "s");
- PyErr_SetString(PyShm_Error, buf);
- return NULL;
- }
- addr = (void *)((unsigned long)self->addr + offset);
- memcpy(addr, data, n);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* List of methods for shared memory objects */
-
-static PyMethodDef memory_methods[] = {
- {"attach", (PyCFunction)PyShmMemory_attach, 1,
- "attach([int Addr=0 [,int How=0]]) --> None | except shm.error"},
- {"detach", (PyCFunction)PyShmMemory_detach, 0,
- "detach() --> None | except shm.error"},
- {"read", (PyCFunction)PyShmMemory_read, 1,
- "read(int Nbytes [,int Offset=0]) --> string | except shm.error"},
- {"setgid", (PyCFunction)PyShmMemory_setgid, 1,
- "setgid(int Gid) --> None | except shm.error"},
- {"setperm", (PyCFunction)PyShmMemory_setperm, 1,
- "setperm(int Perm) --> None | except shm.error"},
- {"setuid", (PyCFunction)PyShmMemory_setuid, 1,
- "setuid(int Uid) --> None | except shm.error"},
- {"write", (PyCFunction)PyShmMemory_write, 1,
- "write(string Data [,int Offset=0]) --> None | except shm.error"},
- {NULL, NULL} /* sentinel */
-};
-
-#define OFF(x) offsetof(PyShmMemoryObject, x)
-#define OFF1(x) OFF(ds) + offsetof(struct shmid_ds, x)
-#define OFF2(x) OFF1(shm_perm) + offsetof(struct ipc_perm, x)
-
-/* List of members for shared memory objects */
-
-/* Note: member types are set in the initshm function.
- Members which need separate processing are:
- - addr --> it is not part of the shmid_ds structure
- - attached --> function depending on addr
- - nattch --> system dependent declaration in shmid_ds (unknown type)
- - perm --> return permission (lower 9) bits only of ds.shm_perm.mode
-*/
-
-static struct memberlist memory_memberlist[] = {
- {"cgid", T_INT, OFF2(cgid), RO}, /* 0 (gid_t) */
- {"cpid", T_INT, OFF1(shm_cpid), RO}, /* 1 (pid_t) */
- {"cuid", T_INT, OFF2(cuid), RO}, /* 2 (uid_t) */
- {"key", T_INT, OFF2(IPC_PERM_KEY_NAME), RO}, /* 3 (key_t) */
- {"lpid", T_INT, OFF1(shm_lpid), RO}, /* 4 (pid_t) */
- {"shmid", T_INT, OFF(shmid), RO}, /* 5 (int) */
- {"size", T_INT, OFF1(shm_segsz), RO}, /* 6 (int) */
- {"gid", T_INT, OFF2(gid), RO}, /* 7 (gid_t) */
- {"uid", T_INT, OFF2(uid), RO}, /* 8 (uid_t) */
- /* The following members are implemented without this table */
- {"addr", T_INT, 0, RO}, /* 9 (void *) */
- {"attached",T_INT, 0, RO}, /* 10 (int) */
- {"nattch", T_INT, 0, RO}, /* 11 sys.dep. */
- {"perm", T_INT, 0, RO}, /* 12 (mode_t) */
- {NULL} /* sentinel */
-};
-
-#undef OFF
-#undef OFF1
-#undef OFF2
-
-static void
-PyShmMemory_dealloc(PyShmObj *self)
-{
- /* del shm_dict[key], ignore if it fails */
- if (PyDict_DelItem(shm_dict, PyInt_FromLong(self->shmid)) == -1)
- PyErr_Clear();
- /* all references in the current process to the shared
- memory segment are lost, so if attached, detach it.
- XXX: This is not true when Python is embedded.
-
- if (self->addr != NULL) {
- shmdt(self->addr);
- }
- */
- /* v1.1 - changed the reference below from PyMem_DEL to PyObject_Del. */
- PyObject_Del(self);
-}
-
-static PyObject *
-PyShmMemory_getattr(PyShmObj *self, char *name)
-{
- PyObject *res;
-
- res = Py_FindMethod(memory_methods, (PyObject *)self, name);
- if (res != NULL)
- return res;
- PyErr_Clear();
- refresh_memory_status(self);
- if (strcmp(name, "attached") == 0)
- return PyInt_FromLong((self->addr == NULL) ? 0 : 1);
- if (strcmp(name, "addr") == 0) {
- if (self->addr != NULL)
- return PyInt_FromLong((unsigned long)self->addr);
- else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- if (strcmp(name, "nattch") == 0)
- return PyInt_FromLong(self->ds.shm_nattch);
- if (strcmp(name, "perm") == 0)
- return PyInt_FromLong(self->ds.shm_perm.mode & 0777);
- return PyMember_Get((char *)self, memory_memberlist, name);
-}
-
-static PyObject *
-PyShmMemory_repr(PyShmObj *self, char *name)
-{
- char buf[100];
- char buf2[20];
-
- refresh_memory_status(self);
- if (self->addr == NULL)
- sprintf(buf2, "None");
- else
- /* v 1.1 - changed format from %lx to %p. */
- /* v 1.1.2 - changed %u to %zu. */
- sprintf(buf2, "0x%p", self->addr);
- sprintf(buf, "<%s shared memory object, id=%d, size=%zu, addr=%s>",
- (self->addr == NULL) ? "detached" : (self->mode & SHM_RDONLY) ?
- "attached RO" : "attached R/W",
- self->shmid,
- self->ds.shm_segsz,
- buf2);
- return PyString_FromString(buf);
-}
-
-/* Type object for shared memory objects */
-
-static PyTypeObject PyShmMemory_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /*ob_size*/
- "shared memory", /*tp_name*/
- sizeof(PyShmObj), /*tp_size*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PyShmMemory_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)PyShmMemory_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc)PyShmMemory_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
-};
-
-/************************************************************/
-/* Semaphore Objects */
-/************************************************************/
-
-/* This is to check the validity of a Python semaphore object */
-
-static int
-check_semaphore_identity(PyShmSemObj *o)
-{
- int new_semid;
- int old_semid = o->semid;
- unsigned short old_nsems = o->ds.sem_nsems;
- key_t old_key = o->ds.sem_perm.IPC_PERM_KEY_NAME;
- semctl_arg arg;
-
- if (old_key != IPC_PRIVATE) {
- new_semid = semget(old_key, 0, 0);
- if (new_semid != old_semid)
- return 0;
- }
- else
- new_semid = old_semid;
- arg.buf = &(o->ds);
- if ((semctl(new_semid, 0, IPC_STAT, arg) != -1) &&
- (old_nsems == o->ds.sem_nsems) &&
- (old_key == o->ds.sem_perm.IPC_PERM_KEY_NAME))
- return 1;
- return 0;
-}
-
-/* Convenience macro for updating the semaphore data status structure */
-
-#define refresh_semaphore_status(o) \
- if (!check_semaphore_identity(o)) { \
- PyErr_SetString(PyShm_Error, \
- "can't access semaphore"); \
- return NULL; \
- }
-
-/*
--- P()
-*/
-
-static PyObject *
-PyShmSemaphore_P(PyShmSemObj *self, PyObject *args)
-{
- struct sembuf op[1];
- int res;
-
- op[0].sem_num = 0;
- op[0].sem_op = -1;
- op[0].sem_flg = self->opflag;
-
- if (!PyArg_NoArgs(args))
- return NULL;
- refresh_semaphore_status(self);
- Py_BEGIN_ALLOW_THREADS
- res = semop(self->semid, op, (size_t)1);
- Py_END_ALLOW_THREADS
- if (res == -1)
- return PyShm_Err();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- V()
-*/
-
-static PyObject *
-PyShmSemaphore_V(PyShmSemObj *self, PyObject *args)
-{
- struct sembuf op[1];
- int res;
-
- op[0].sem_num = 0;
- op[0].sem_op = 1;
- op[0].sem_flg = self->opflag;
-
- if (!PyArg_NoArgs(args))
- return NULL;
- refresh_semaphore_status(self);
- Py_BEGIN_ALLOW_THREADS
- res = semop(self->semid, op, (size_t)1);
- Py_END_ALLOW_THREADS
- if (res == -1)
- return PyShm_Err();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- Z()
-*/
-
-static PyObject *
-PyShmSemaphore_Z(PyShmSemObj *self, PyObject *args)
-{
- struct sembuf op[1];
- int res;
-
- op[0].sem_num = 0;
- op[0].sem_op = 0;
- op[0].sem_flg = self->opflag;
-
- if (!PyArg_NoArgs(args))
- return NULL;
- refresh_semaphore_status(self);
- Py_BEGIN_ALLOW_THREADS
- res = semop(self->semid, op, (size_t)1);
- Py_END_ALLOW_THREADS
- if (res == -1)
- return PyShm_Err();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setblocking(0|1)
-*/
-
-static PyObject *
-PyShmSemaphore_setblocking(PyShmSemObj *self, PyObject *args)
-{
- int block;
-
- if (!PyArg_ParseTuple(args, "i", &block))
- return NULL;
- refresh_semaphore_status(self);
- if (block)
- self->opflag &= ~IPC_NOWAIT;
- else
- self->opflag |= IPC_NOWAIT;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setgid(int Gid)
-*/
-
-static PyObject *
-PyShmSemaphore_setgid(PyShmSemObj *self, PyObject *args)
-{
- long newgid, oldgid;
- semctl_arg arg;
-
- if (!PyArg_ParseTuple(args, "l", &newgid))
- return NULL;
- refresh_semaphore_status(self);
- oldgid = (long)self->ds.sem_perm.gid;
- self->ds.sem_perm.gid = (gid_t)newgid;
- arg.buf = &(self->ds);
- if (semctl(self->semid, 0, IPC_SET, arg) == -1) {
- self->ds.sem_perm.gid = (gid_t)oldgid;
- return PyShm_Err();
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setperm(int Perm)
-*/
-
-static PyObject *
-PyShmSemaphore_setperm(PyShmSemObj *self, PyObject *args)
-{
- long newmode, oldmode;
- semctl_arg arg;
-
- if (!PyArg_ParseTuple(args, "l", &newmode))
- return NULL;
- refresh_semaphore_status(self);
- newmode &= 0777; /* permission bits only */
- oldmode = (mode_t)self->ds.sem_perm.mode;
- self->ds.sem_perm.mode ^= 0777;
- self->ds.sem_perm.mode |= (mode_t)newmode;
- arg.buf = &(self->ds);
- if (semctl(self->semid, 0, IPC_SET, arg) == -1) {
- self->ds.sem_perm.mode = (mode_t)oldmode;
- return PyShm_Err();
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setuid(int Uid)
-*/
-
-static PyObject *
-PyShmSemaphore_setuid(PyShmSemObj *self, PyObject *args)
-{
- long newuid, olduid;
- semctl_arg arg;
-
- if (!PyArg_ParseTuple(args, "l", &newuid))
- return NULL;
- refresh_semaphore_status(self);
- olduid = (long)self->ds.sem_perm.uid;
- /* v1.1 - fixed typo that set the group id rather than the user id */
- self->ds.sem_perm.uid = (uid_t)newuid;
- arg.buf = &(self->ds);
- if (semctl(self->semid, 0, IPC_SET, arg) == -1) {
- self->ds.sem_perm.uid = (uid_t)olduid;
- return PyShm_Err();
- }
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setundo(0|1)
-*/
-
-static PyObject *
-PyShmSemaphore_setundo(PyShmSemObj *self, PyObject *args)
-{
- int undo;
-
- if (!PyArg_ParseTuple(args, "i", &undo))
- return NULL;
- refresh_semaphore_status(self);
- if (undo)
- self->opflag |= SEM_UNDO;
- else
- self->opflag &= ~SEM_UNDO;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- setval(int Value)
-*/
-
-static PyObject *
-PyShmSemaphore_setval(PyShmSemObj *self, PyObject *args)
-{
- int value;
- semctl_arg arg;
-
- if (!PyArg_ParseTuple(args, "i", &value))
- return NULL;
- refresh_semaphore_status(self);
- arg.val = value;
- if (semctl(self->semid, 0, SETVAL, arg) == -1)
- return PyShm_Err();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* List of methods for semaphore objects */
-
-static PyMethodDef semaphore_methods[] = {
- {"P", (PyCFunction)PyShmSemaphore_P, 0,
- "P() --> None | except shm.error"},
- {"V", (PyCFunction)PyShmSemaphore_V, 0,
- "V() --> None | except shm.error"},
- {"Z", (PyCFunction)PyShmSemaphore_Z, 0,
- "Z() --> None | except shm.error"},
- {"setblocking", (PyCFunction)PyShmSemaphore_setblocking, 1,
- "setblocking(0|1) --> None"},
- {"setgid", (PyCFunction)PyShmSemaphore_setgid, 1,
- "setgid(int Gid) --> None | except shm.error"},
- {"setperm", (PyCFunction)PyShmSemaphore_setperm, 1,
- "setperm(int Perm) --> None | except shm.error"},
- {"setuid", (PyCFunction)PyShmSemaphore_setuid, 1,
- "setuid(int Uid) --> None | except shm.error"},
- {"setundo", (PyCFunction)PyShmSemaphore_setundo, 1,
- "setundo(0|1) --> None"},
- {"setval", (PyCFunction)PyShmSemaphore_setval, 1,
- "setval(int Value) --> None | except shm.error"},
- {NULL, NULL} /* sentinel */
-};
-
-#define OFF(x) offsetof(PyShmSemaphoreObject, x)
-#define OFF1(x) OFF(ds) + offsetof(struct semid_ds, x)
-#define OFF2(x) OFF1(sem_perm) + offsetof(struct ipc_perm, x)
-
-/* List of members for semaphore objects */
-
-/* Note: member types are set in the initshm function.
- Members which need separate processing are:
- - val, lpid, ncnt, zcnt --> in kernel memory, not accessible from a process
- - perm --> return permission (lower 9) bits only of ds.sem_perm.mode
- - blocking --> in opflags
-*/
-
-static struct memberlist semaphore_memberlist[] = {
- {"cgid", T_INT, OFF2(cgid), RO}, /* 0 (gid_t) */
- {"cuid", T_INT, OFF2(cuid), RO}, /* 1 (uid_t) */
- {"key", T_INT, OFF2(IPC_PERM_KEY_NAME), RO}, /* 2 (key_t) */
- {"semid", T_INT, OFF(semid), RO}, /* 3 (int) */
- {"gid", T_INT, OFF2(gid), RO}, /* 4 (gid_t) */
- {"uid", T_INT, OFF2(uid), RO}, /* 5 (uid_t) */
- /* The following members are implemented without this table */
- {"lpid", T_INT, 0, RO}, /* 6 (ushort) */
- {"ncnt", T_INT, 0, RO}, /* 7 (ushort) */
- {"perm", T_INT, 0, RO}, /* 8 (mode_t) */
- {"val", T_INT, 0, RO}, /* 9 (ushort) */
- {"zcnt", T_INT, 0, RO}, /* 10 (ushort) */
- {"blocking",T_INT, 0, RO}, /* 11 (ushort) */
- {NULL} /* sentinel */
-};
-
-#undef OFF
-#undef OFF1
-#undef OFF2
-
-static void
-PyShmSemaphore_dealloc(PyShmSemObj *self)
-{
- /* del sem_dict[key], ignore if it fails */
- if (PyDict_DelItem(sem_dict, PyInt_FromLong(self->semid)) == -1)
- PyErr_Clear();
- /* v1.1 - changed the reference below from PyMem_DEL to PyObject_Del. */
- PyObject_Del(self);
-}
-
-static PyObject *
-PyShmSemaphore_getattr(PyShmSemObj *self, char *name)
-{
- PyObject *res;
-
- res = Py_FindMethod(semaphore_methods, (PyObject *)self, name);
- if (res != NULL)
- return res;
- PyErr_Clear();
- refresh_semaphore_status(self);
- if (strcmp(name, "val") == 0)
- return PyInt_FromLong(semctl(self->semid, 0, GETVAL, 0));
- if (strcmp(name, "lpid") == 0)
- return PyInt_FromLong(semctl(self->semid, 0, GETPID, 0));
- if (strcmp(name, "ncnt") == 0)
- return PyInt_FromLong(semctl(self->semid, 0, GETNCNT, 0));
- if (strcmp(name, "zcnt") == 0)
- return PyInt_FromLong(semctl(self->semid, 0, GETZCNT, 0));
- if (strcmp(name, "perm") == 0)
- return PyInt_FromLong(self->ds.sem_perm.mode & 0777);
- /* v1.1 - added blocking */
- if (strcmp(name, "blocking") == 0)
- return PyInt_FromLong(self->opflag & IPC_NOWAIT ? 0 : 1);
- return PyMember_Get((char *)self, semaphore_memberlist, name);
-}
-
-static PyObject *
-PyShmSemaphore_repr(PyShmSemObj *self, char *name)
-{
- /* v1.1 - added blocking */
- char buf[200];
-
- refresh_semaphore_status(self);
- sprintf(buf, "<semaphore object, id=%d, val=%d, ncnt=%d, zcnt=%d, blocking=%d>",
- self->semid,
- semctl(self->semid, 0, GETVAL, 0),
- semctl(self->semid, 0, GETNCNT, 0),
- semctl(self->semid, 0, GETZCNT, 0),
- self->opflag & IPC_NOWAIT ? 0 : 1);
- return PyString_FromString(buf);
-}
-
-/* Type object for semaphore objects */
-
-static PyTypeObject PyShmSemaphore_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /*ob_size*/
- "semaphore", /*tp_name*/
- sizeof(PyShmSemObj), /*tp_size*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PyShmSemaphore_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)PyShmSemaphore_getattr,/*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc)PyShmSemaphore_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
-};
-
-/************************************************************/
-/* Module Interface */
-/************************************************************/
-
-/*
--- ftok(string Path, int ProjId) -> int
-*/
-
-/* Compute a key by using the system's ftok algorithm */
-
-static PyObject *
-PyShm_ftok(PyObject *self, PyObject *args)
-{
- char *path;
- char id;
- key_t key;
-
- if (!PyArg_ParseTuple(args, "sb", &path, &id))
- return NULL;
- key = ftok(path, id);
- return PyInt_FromLong((long)key);
-}
-
-/*
--- getshmid(int Key) --> int | except KeyError
-*/
-
-/* Return a shared memory segment id from a given key */
-
-static PyObject *
-PyShm_getshmid(PyObject *self, PyObject *args)
-{
- long key;
- int shmid;
-
- if (!PyArg_ParseTuple(args, "l", &key))
- return NULL;
- shmid = shmget((key_t)key, 0, 0);
- if (shmid == -1) {
- PyErr_SetObject(PyExc_KeyError, PyInt_FromLong(key));
- return NULL;
- }
- return PyInt_FromLong(shmid);
-}
-
-/*
--- memory_haskey(int Key) --> int
-*/
-
-/* Check whether there is a shared memory segment with the given key */
-
-static PyObject *
-PyShm_memory_haskey(PyObject *self, PyObject *args)
-{
- long key;
- int shmid;
-
- if (!PyArg_ParseTuple(args, "l", &key))
- return NULL;
- shmid = shmget((key_t)key, 0, 0);
- return PyInt_FromLong((shmid == -1) ? 0 : 1);
-}
-
-/*
--- memory(int Shmid) --> object | except shm.error
-*/
-
-/* Get an existing shared memory segment and return it as a python object. */
-
-static PyObject *
-PyShm_memory(PyObject *self, PyObject *args)
-{
- int shmid;
- PyShmObj *o;
- PyObject *keyo;
-
- if (!PyArg_ParseTuple(args, "i", &shmid))
- return NULL;
- keyo = PyInt_FromLong(shmid);
- /* get the object from the dictionary */
- if (PyMapping_HasKey(shm_dict, keyo)) {
- o = (PyShmObj *)PyDict_GetItem(shm_dict, keyo);
- Py_INCREF(o);
- }
- else {
- /* not found, create it */
- if ((o = PyObject_NEW(PyShmObj, &PyShmMemory_Type)) == NULL)
- return NULL;
- o->shmid = shmid;
- o->addr = NULL;
- o->mode = 0;
- /* shm_dict[shmid] = o */
- if (PyDict_SetItem(shm_dict, keyo, (PyObject *)o) == -1) {
- Py_DECREF(o);
- PyErr_SetString(PyShm_Error, "can't initialize shared memory object");
- return NULL;
- }
- Py_DECREF(o); /* the owned reference in shm_dict doesn't count! */
- }
- /* v1.1 - plugged memory leak */
- Py_DECREF(keyo);
- /* set up the status data */
- if (shmctl(o->shmid, IPC_STAT, &(o->ds)) == -1) {
- Py_DECREF(o);
- PyErr_SetString(PyShm_Error, "can't access shared memory segment");
- return NULL;
- }
- return (PyObject *)o;
-}
-
-/*
--- create_memory(int Key, int Size [,int Perm=0666]) --> object
-*/
-
-/* Create a new shared memory segment. */
-
-static PyObject *
-PyShm_create_memory(PyObject *self, PyObject *args)
-{
- long key;
- int size, shmid;
- int perm = 0666; /* Default permission is -rw-rw-rw- */
- PyObject *py_shmid;
- PyObject *memory;
-
- if (!PyArg_ParseTuple(args, "li|i", &key, &size, &perm))
- return NULL;
- shmid = shmget((key_t)key, size, perm | IPC_CREAT | IPC_EXCL);
- if (shmid == -1)
- return PyShm_Err();
- /* v1.1 - fixed memory leak resulting from inlining Py_BuildValue */
- py_shmid = Py_BuildValue("(i)", shmid);
- memory = PyShm_memory(self, py_shmid);
- Py_DECREF(py_shmid);
-
- return memory;
-}
-
-/*
--- remove_memory(int Shmid) --> None | except shm.error
-*/
-
-/* Remove an existing shared memory segment. */
-
-static PyObject *
-PyShm_remove_memory(PyObject *self, PyObject *args)
-{
- int shmid, res;
-
- if (!PyArg_ParseTuple(args, "i", &shmid))
- return NULL;
- res = shmctl(shmid, IPC_RMID, 0); /* remove it */
- if (res == -1)
- return PyShm_Err();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*
--- getsemid(int Key) --> int | except KeyError
-*/
-
-/* Return a semaphore id from a given key */
-
-static PyObject *
-PyShm_getsemid(PyObject *self, PyObject *args)
-{
- long key;
- int semid;
-
- if (!PyArg_ParseTuple(args, "l", &key))
- return NULL;
- semid = semget((key_t)key, 0, 0);
- if (semid == -1) {
- PyErr_SetObject(PyExc_KeyError, PyInt_FromLong(key));
- return NULL;
- }
- return PyInt_FromLong(semid);
-}
-
-/*
--- semaphore_haskey(int Key) --> int
-*/
-
-/* Check whether there is a semaphore with the given key */
-
-static PyObject *
-PyShm_semaphore_haskey(PyObject *self, PyObject *args)
-{
- long key;
- int semid;
-
- if (!PyArg_ParseTuple(args, "l", &key))
- return NULL;
- semid = semget((key_t)key, 0, 0);
- return PyInt_FromLong((semid == -1) ? 0 : 1);
-}
-
-/*
--- semaphore(int Semid) --> object
-*/
-
-/* Get an existing semaphore and return it as a python object. */
-
-static PyObject *
-PyShm_semaphore(PyObject *self, PyObject *args)
-{
- int semid;
- PyShmSemObj *o;
- PyObject *keyo;
- semctl_arg arg;
-
- if (!PyArg_ParseTuple(args, "i", &semid))
- return NULL;
- keyo = PyInt_FromLong(semid);
- /* get the object from the dictionary */
- if (PyMapping_HasKey(sem_dict, keyo)) {
- o = (PyShmSemObj *)PyDict_GetItem(sem_dict, keyo);
- Py_INCREF(o);
- }
- else {
- /* not found, create it */
- if ((o = PyObject_NEW(PyShmSemObj, &PyShmSemaphore_Type)) == NULL)
- return NULL;
- o->semid = semid;
- o->opflag = 0;
- /* sem_dict[semid] = o */
- if (PyDict_SetItem(sem_dict, keyo, (PyObject *)o) == -1) {
- Py_DECREF(o);
- PyErr_SetString(PyShm_Error, "can't initialize semaphore object");
- return NULL;
- }
- Py_DECREF(o); /* the owned reference in sem_dict doesn't count! */
- }
- /* v1.1 - plugged memory leak */
- Py_DECREF(keyo);
- /* set up the status data */
- arg.buf = &(o->ds);
- if (semctl(o->semid, 0, IPC_STAT, arg) == -1) {
- Py_DECREF(o);
- PyErr_SetString(PyShm_Error, "can't access semaphore");
- return NULL;
- }
- return (PyObject *)o;
-}
-
-/*
--- create_semaphore(int Key, [,int Value=1 [,int Perm=0666]]) --> object
-*/
-
-/* Create a new semaphore. */
-
-static PyObject *
-PyShm_create_semaphore(PyObject *self, PyObject *args)
-{
- long key;
- int semid;
- int value = 1;
- int perm = 0666; /* Default permission is -rw-rw-rw- */
- semctl_arg arg;
- PyObject *py_shmid;
- PyObject *semaphore;
-
- if (!PyArg_ParseTuple(args, "l|ii", &key, &value, &perm))
- return NULL;
- semid = semget((key_t)key, 1, perm | IPC_CREAT | IPC_EXCL);
- arg.val = value;
- if (!((semid != -1) && (semctl(semid, 0, SETVAL, arg) != -1)))
- return PyShm_Err();
- /* v1.1 - fixed memory leak resulting from inlining Py_BuildValue */
- py_shmid = Py_BuildValue("(i)", semid);
- semaphore = PyShm_semaphore(self, py_shmid);
- Py_DECREF(py_shmid);
-
- return semaphore;
-}
-
-/*
--- remove_semaphore(int Semid) --> None | except shm.error
-*/
-
-/* Remove an existing semaphore. */
-
-static PyObject *
-PyShm_remove_semaphore(PyObject *self, PyObject *args)
-{
- int semid, res;
-
- if (!PyArg_ParseTuple(args, "i", &semid))
- return NULL;
- res = semctl(semid, 0, IPC_RMID, 0); /* remove it */
- if (res == -1)
- return PyShm_Err();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* List of functions exported by this module. */
-
-static PyMethodDef PyShm_methods[] = {
- {"create_memory", PyShm_create_memory, 1,
- "create_memory(int Key, int Size [,int Perm=0666]) --> object | except shm.error"},
- {"create_semaphore", PyShm_create_semaphore, 1,
- "create_semaphore(int Key [,int Value=1 [,int Perm=0666]]) --> object | except shm.error"},
- {"ftok", PyShm_ftok, 1,
- "ftok(string Path, int ProjId) --> int | except shm.error"},
- {"getsemid", PyShm_getsemid, 1,
- "getsemid(int Key) --> int | except KeyError"},
- {"getshmid", PyShm_getshmid, 1,
- "getshmid(int Key) --> int | except KeyError"},
- {"memory_haskey", PyShm_memory_haskey, 1,
- "memory_haskey(int Key) --> int"},
- {"memory", PyShm_memory, 1,
- "memory(int Shmid) --> object | except shm.error"},
- {"semaphore", PyShm_semaphore, 1,
- "semaphore(int Semid) --> object | except shm.error"},
- {"semaphore_haskey", PyShm_semaphore_haskey, 1,
- "semaphore_haskey(int Key) --> int"},
- {"remove_memory", PyShm_remove_memory, 1,
- "remove_memory(int Shmid) --> None | except shm.error"},
- {"remove_semaphore", PyShm_remove_semaphore, 1,
- "remove_semaphore(int Semid) --> None | except shm.error"},
- {NULL, NULL} /* Sentinel */
-};
-
-
-/* Initialize this module */
-
-/* This is for inserting constants in the module's dictionary */
-
-static void
-insint(PyObject *d, char *name, int value)
-{
- PyObject *v = PyInt_FromLong((long) value);
- if (!v || PyDict_SetItemString(d, name, v))
- Py_FatalError("can't initialize shm module");
-
- Py_DECREF(v);
-}
-
-/* This is to set up the type of shared memory/semaphore object members */
-
-static void
-set_member_type(struct memberlist *sxm_memberlist,
- int index, /* index in memberlist */
- int typesize /* sizeof(member_type) */
- )
-{
- int t;
-
- if (typesize == sizeof(char))
- t = T_UBYTE;
- else if (typesize == sizeof(short))
- t = T_USHORT;
- else if (typesize == sizeof(int))
- t = T_UINT;
- else if (typesize == sizeof(long))
- t = T_ULONG;
- else
- Py_FatalError("can't initialize shm module");
- sxm_memberlist[index].type = t;
-};
-
-void
-initshm(void)
-{
- PyObject *m, *d;
-
- m = Py_InitModule("shm", PyShm_methods);
- d = PyModule_GetDict(m);
- PyShm_Error = PyString_FromString("shm.error");
- if (PyShm_Error == NULL ||
- PyDict_SetItemString(d, "error", PyShm_Error) != 0)
- Py_FatalError("can't define shm.error");
- if (PyDict_SetItemString(d, "__doc__", PyString_FromString
- ("Interface to System V shared memory IPC")) != 0)
- Py_FatalError("can't define shm.__doc__");
- if ((shm_dict = PyDict_New()) == NULL || (sem_dict = PyDict_New()) == NULL)
- Py_FatalError("can't initialize shm module");
-
- /* initialize the machine dependent types in memory_memberlist */
- set_member_type(memory_memberlist, 0, sizeof(gid_t)); /* cgid */
- set_member_type(memory_memberlist, 1, sizeof(pid_t)); /* cpid */
- set_member_type(memory_memberlist, 2, sizeof(uid_t)); /* cuid */
- set_member_type(memory_memberlist, 3, sizeof(key_t)); /* key */
- set_member_type(memory_memberlist, 4, sizeof(pid_t)); /* lpid */
- set_member_type(memory_memberlist, 5, sizeof(int)); /* shmid */
- set_member_type(memory_memberlist, 6, sizeof(int)); /* size */
- set_member_type(memory_memberlist, 7, sizeof(gid_t)); /* gid */
- set_member_type(memory_memberlist, 8, sizeof(uid_t)); /* uid */
-
- /* initialize the machine dependent types in semaphore_memberlist */
- set_member_type(semaphore_memberlist, 0, sizeof(gid_t)); /* cgid */
- set_member_type(semaphore_memberlist, 1, sizeof(uid_t)); /* cuid */
- set_member_type(semaphore_memberlist, 2, sizeof(key_t)); /* key */
- set_member_type(semaphore_memberlist, 3, sizeof(int)); /* semid */
- set_member_type(semaphore_memberlist, 4, sizeof(gid_t)); /* gid */
- set_member_type(semaphore_memberlist, 5, sizeof(uid_t)); /* uid */
-
- /* relevant constants for this module; the others are useless here */
- insint(d, "IPC_PRIVATE", IPC_PRIVATE);
- insint(d, "SHM_RDONLY", SHM_RDONLY);
- insint(d, "SHM_RND", SHM_RND);
-#ifdef SHMLBA
- insint(d, "SHMLBA", SHMLBA);
-#endif
-#ifdef SEM_A
- insint(d, "SEM_A", SEM_A);
-#endif
-#ifdef SEM_R
- insint(d, "SEM_R", SEM_R);
-#endif
-#ifdef SHM_R
- insint(d, "SHM_R", SHM_R);
-#endif
-#ifdef SHM_W
- insint(d, "SHM_W", SHM_W);
-#endif
-}
diff --git a/doc/Changelog b/doc/Changelog
index 8831fdd..2d16030 100644
--- a/doc/Changelog
+++ b/doc/Changelog
@@ -7,6 +7,8 @@
- now showing slots in the version list
- added Turkish translation (thx to Gürkan Gür)
- appended important version information to the exceptions
+- also display useflag descriptions from overlays
+- fixes lots of errors
0.9.0.3:
- removed the "expanding bug" in 0.9.0.2
diff --git a/doc/TRANSLATORS b/doc/TRANSLATORS
index 131ddd6..8d5ca81 100644
--- a/doc/TRANSLATORS
+++ b/doc/TRANSLATORS
@@ -1,4 +1,4 @@
Catalan: Roger Calvó
German: René 'Necoro' Neumann
Polish: Tomasz Osiński
-Turkish: Gürkan Gür
+Turkish: Gürkan 'seqizz' Gür
diff --git a/icons/pausing.png b/icons/pausing.png
new file mode 100644
index 0000000..af4bf6b
--- /dev/null
+++ b/icons/pausing.png
Binary files differ
diff --git a/icons/pausing.svg b/icons/pausing.svg
new file mode 100644
index 0000000..0d8f05a
--- /dev/null
+++ b/icons/pausing.svg
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg13610"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docbase="/home/p4r4d0x"
+ sodipodi:docname="pausing.svg"
+ version="1.0"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs13612">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 24 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="48 : 24 : 1"
+ inkscape:persp3d-origin="24 : 16 : 1"
+ id="perspective5726" />
+ <linearGradient
+ id="linearGradient13604">
+ <stop
+ id="stop13606"
+ offset="0"
+ style="stop-color:black;stop-opacity:1" />
+ <stop
+ id="stop13608"
+ offset="1"
+ style="stop-color:black;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient13604"
+ id="linearGradient13602"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.284415,6.386495e-2,-6.386495e-2,0.284415,89.18451,-34.55003)"
+ x1="-95.701729"
+ y1="273.27039"
+ x2="-249.1709"
+ y2="203.87448" />
+ <linearGradient
+ id="linearGradient4778">
+ <stop
+ id="stop4780"
+ offset="0"
+ style="stop-color:#a70b0e;stop-opacity:1;" />
+ <stop
+ id="stop4782"
+ offset="1"
+ style="stop-color:#ff060b;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4778"
+ id="linearGradient13592"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1,0,0,-1,195.5156,535.8543)"
+ x1="155.0766"
+ y1="338.61826"
+ x2="164.46457"
+ y2="351.01041" />
+ <linearGradient
+ id="linearGradient12647">
+ <stop
+ id="stop12649"
+ offset="0"
+ style="stop-color:#0f7518;stop-opacity:1" />
+ <stop
+ id="stop12651"
+ offset="1"
+ style="stop-color:#3cd53c;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient12647"
+ id="linearGradient13590"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(162.3369,-65.67832)"
+ x1="-251.50606"
+ y1="234.85478"
+ x2="-198.36317"
+ y2="234.85478" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="3.8246377"
+ inkscape:cx="75.714286"
+ inkscape:cy="24.691171"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1280"
+ inkscape:window-height="936"
+ inkscape:window-x="439"
+ inkscape:window-y="32"
+ width="48px"
+ height="48px"
+ borderlayer="true"
+ showgrid="false" />
+ <metadata
+ id="metadata13615">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ style="opacity:0.17821781;fill:url(#linearGradient13602);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00000012;stroke-miterlimit:4;stroke-opacity:1;display:inline"
+ d="M 21.225645,4.4504907 C 21.503176,6.3926183 22.056369,8.251059 22.531152,10.111913 C 16.272005,8.9661448 9.0127714,8.7235731 3.7553721,12.776562 C 0.67431831,15.409426 0.36171424,20.277273 2.6002252,23.533804 C 6.7197311,30.722653 15.247592,33.470749 21.100273,38.959132 C 22.941564,40.62556 24.514271,42.5555 26.060337,44.495766 C 26.018215,42.088131 25.376596,39.704294 25.264982,37.352421 C 31.540377,38.526117 38.842097,38.782059 44.147416,34.711722 C 47.228147,32.059367 47.537334,27.181282 45.268103,23.900062 C 40.851766,16.353866 31.779571,13.669381 25.742087,7.7284038 C 23.956199,6.0506631 22.408513,4.1495441 20.802584,2.3015452 C 20.943605,3.0178616 21.084625,3.7341747 21.225645,4.4504907 z M 33.145404,18.722525 C 34.808353,21.261529 36.841753,24.50176 35.893137,27.648676 C 33.894477,30.331409 29.996264,30.403139 26.9759,29.940941 C 28.398476,27.576233 29.832867,25.218664 31.256,22.854291 C 26.230941,25.817698 20.882246,28.533731 15.014391,29.159569 C 13.216638,26.463371 11.048146,23.180694 11.989879,19.844504 C 13.961895,17.170631 17.867436,17.071205 20.918001,17.545347 C 19.508072,19.873947 18.096785,22.201725 16.688512,24.531329 C 21.737929,21.661374 27.01701,18.95133 32.872617,18.315835 L 33.034993,18.557918 L 33.145404,18.722525 z "
+ id="path6586" />
+ <g
+ style="opacity:1;display:inline"
+ id="g13586"
+ transform="matrix(0.284415,6.386495e-2,-6.386495e-2,0.284415,38.78299,-27.7267)">
+ <path
+ sodipodi:nodetypes="cscccccss"
+ d="M -21.665963,217.28818 C -41.826853,211.89448 -65.171553,182.79648 -58.342643,171.25628 C -49.406813,156.15549 -26.751143,155.29399 -21.499323,156.19713 L -27.416363,173.80628 C -27.416363,173.80628 1.7241171,147.47765 27.030307,147.15813 C 7.1163671,138.77565 -11.981343,134.144 -29.087063,121.06482 L -21.046963,137.81378 C -57.379533,137.40524 -86.708383,150.5245 -89.021553,170.01928 C -91.528973,191.15108 -61.807683,211.82128 -21.665963,217.28818 z "
+ style="fill:url(#linearGradient13590);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00000012;stroke-miterlimit:4;stroke-opacity:1"
+ id="path12693" />
+ <path
+ id="path12695"
+ style="fill:url(#linearGradient13592);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00000012;stroke-miterlimit:4;stroke-opacity:1"
+ d="M 14.608337,149.21572 C 28.311467,160.34013 38.761947,177.47408 33.896677,185.69598 C 24.960847,200.79668 2.3051771,201.65818 -2.9466429,200.75508 L 2.9703971,183.14588 C 2.9703971,183.14588 -26.170083,209.47458 -51.476273,209.79408 C -31.562333,218.17658 -14.641093,222.08268 2.4646271,235.16188 L -3.3990029,219.13838 C 32.933567,219.54698 62.262417,206.42768 64.575587,186.93288 C 66.408117,171.48888 51.026257,156.29142 26.943247,147.09515 C 20.867687,147.53379 25.093337,146.9126 14.608337,149.21572 z "
+ sodipodi:nodetypes="cscccccscc" />
+ </g>
+ <rect
+ style="opacity:1;fill:#474747;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.234;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect5548"
+ width="7.0891571"
+ height="17.273062"
+ x="13.305499"
+ y="27.597651"
+ inkscape:export-filename="/home/necoro/dev/portato/trunk/icons/rect5552.png"
+ inkscape:export-xdpi="112"
+ inkscape:export-ydpi="112" />
+ <rect
+ style="opacity:1;fill:#474747;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.234;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect5552"
+ width="7.0891571"
+ height="17.273062"
+ x="3.1369846"
+ y="27.597651"
+ inkscape:export-xdpi="112"
+ inkscape:export-ydpi="112" />
+ </g>
+</svg>
diff --git a/portato.py b/portato.py
index 9a068ad..a4f871a 100755
--- a/portato.py
+++ b/portato.py
@@ -73,13 +73,7 @@ def main ():
else: # start us again in root modus and launch listener
- try: # local version
- from _shm import shm_wrapper as shm
- except ImportError:
- try: # version installed together with portato
- from portato._shm import shm_wrapper as shm
- except ImportError: # the normal shm module
- import shm_wrapper as shm
+ import shm_wrapper as shm
mem = shm.create_memory(1024, permissions=0600)
sig = shm.create_semaphore(InitialValue = 0, permissions = 0600)
diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py
index d0a0bc3..fa4fece 100644
--- a/portato/backend/portage/system.py
+++ b/portato/backend/portage/system.py
@@ -31,11 +31,13 @@ class PortageSystem (SystemInterface):
def __init__ (self):
"""Constructor."""
self.settings = PortageSettings()
- portage.WORLD_FILE = os.path.join(self.settings.settings["ROOT"], portage.WORLD_FILE)
+ portage.WORLD_FILE = os.path.join(self.settings.settings["ROOT"],portage.WORLD_FILE)
self.use_descs = {}
self.local_use_descs = defaultdict(dict)
+ self._version = tuple([x.split("_")[0] for x in portage.VERSION.split(".")])
+
def get_version (self):
return "Portage %s" % portage.VERSION
@@ -155,18 +157,24 @@ class PortageSystem (SystemInterface):
return PortagePackage(portage.best(list))
def find_best_match (self, search_key, masked = False, only_installed = False, only_cpv = False):
- t = None
-
+ t = []
+
if not only_installed:
pkgSet = "tree"
else:
pkgSet = "installed"
t = self.find_packages(search_key, pkgSet = pkgSet, masked = masked, with_version = True, only_cpv = True)
+
+ if self._version >= (2,1,5):
+ t += [pkg.get_cpv() for pkg in self.find_installed_packages(search_key) if not (pkg.is_testing(True) or pkg.is_masked())]
if t:
+ t = unique_array(t)
return self.find_best(t, only_cpv)
+ return None
+
def find_packages (self, key = "", pkgSet = "all", masked = False, with_version = True, only_cpv = False):
if key is None: key = ""
@@ -355,7 +363,7 @@ class PortageSystem (SystemInterface):
# append system packages
packages.extend(unique_array([p.get_cp() for p in self.find_packages(pkgSet = "system")]))
- states = [(["RDEPEND"], True)]
+ states = [(["RDEPEND", "PDEPEND"], True)]
if self.with_bdeps():
states.append((["DEPEND"], True))
@@ -431,7 +439,7 @@ class PortageSystem (SystemInterface):
else:
for pkg in bm:
if not pkg: continue
- if pkg.is_masked() or pkg.is_testing(True): # check to not update unnecessairily
+ if not pkg.is_installed() and (pkg.is_masked() or pkg.is_testing(True)): # check to not update unnecessairily
cont = False
for inst in self.find_packages(pkg.get_cp(), "installed", only_cpv = True):
if self.cpv_matches(inst, i):
diff --git a/portato/gui/exception_handling.py b/portato/gui/exception_handling.py
index 6bda133..29cd4e6 100644
--- a/portato/gui/exception_handling.py
+++ b/portato/gui/exception_handling.py
@@ -118,6 +118,7 @@ def get_version_infos():
return "\n".join((
"Portato version: %s" % VERSION,
+ "Python version: %s" % sys.version,
"Used backend: %s" % system.get_version(),
"pygtk: %s (using GTK+: %s)" % (convert(gtk.pygtk_version), convert(gtk.gtk_version)),
"pygobject: %s (using GLib: %s)" % (convert(gobject.pygobject_version), convert(gobject.glib_version)),
diff --git a/portato/gui/templates/AboutWindow.glade b/portato/gui/templates/AboutWindow.glade
index 57708d9..d5cfbef 100644
--- a/portato/gui/templates/AboutWindow.glade
+++ b/portato/gui/templates/AboutWindow.glade
@@ -16,7 +16,7 @@
<property name="has_separator">False</property>
<property name="program_name">Portato</property>
<property name="copyright" translatable="yes">This software is licensed under the terms of the GPLv2.
-Copyright (C) 2006-2007 René 'Necoro' Neumann &lt;necoro@necoro.net&gt;</property>
+Copyright (C) 2006-2008 René 'Necoro' Neumann &lt;necoro@necoro.net&gt;</property>
<property name="comments">A Portage GUI</property>
<property name="website">http://portato.necoro.net</property>
<property name="authors">René 'Necoro' Neumann
@@ -28,7 +28,7 @@ Thanks goto:
<property name="translator_credits">Catalan - Roger Calvó
German - René 'Necoro' Neumann
Polish - Tomasz Osiński
-Turkish - Gürkan Gür</property>
+Turkish - Gürkan 'seqizz' Gür</property>
<property name="artists">p4r4d0x (inspired by wolfden)</property>
<signal name="response" handler="close"/>
<child internal-child="vbox">
diff --git a/portato/gui/templates/MainWindow.glade b/portato/gui/templates/MainWindow.glade
index 7422126..788a339 100644
--- a/portato/gui/templates/MainWindow.glade
+++ b/portato/gui/templates/MainWindow.glade
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.3 on Fri Apr 11 14:08:36 2008 -->
+<!--Generated with glade3 3.4.3 on Mon Apr 21 23:09:43 2008 -->
<glade-interface>
<widget class="GtkWindow" id="MainWindow">
<property name="border_width">2</property>
@@ -46,6 +46,8 @@
<property name="label" translatable="yes">Re_load Portage</property>
<property name="use_underline">True</property>
<signal name="activate" handler="cb_reload_clicked"/>
+ <accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+ <accelerator key="F5" modifiers="" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image9">
<property name="visible">True</property>
@@ -614,271 +616,271 @@
<placeholder/>
</child>
<child>
- <widget class="GtkLabel" id="licenseLabel">
+ <widget class="GtkLabel" id="useFlagsLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="no_show_all">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">label</property>
+ <property name="label">use flags</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="licenseLabelLabel">
+ <widget class="GtkLabel" id="useFlagsLabelLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="no_show_all">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;License:&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;b&gt;Use Flags:&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">5</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="notInSysLabel">
+ <widget class="GtkCheckButton" id="testingCheck">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="no_show_all">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Installed, but not in portage anymore&lt;/b&gt;</property>
- <property name="use_markup">True</property>
+ <property name="label" translatable="yes">Testing</property>
+ <property name="xalign">0</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="cb_testing_toggled"/>
</widget>
<packing>
- <property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="missingLabel">
+ <widget class="GtkLabel" id="maskedLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes">&lt;span foreground='red'&gt;&lt;b&gt;MISSING KEYWORD&lt;/b&gt;&lt;/span&gt;</property>
- <property name="use_markup">True</property>
+ <property name="xalign">0</property>
</widget>
<packing>
+ <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="linkBox">
+ <widget class="GtkCheckButton" id="maskedCheck">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">5</property>
- <child>
- <placeholder/>
- </child>
+ <property name="no_show_all">True</property>
+ <property name="label" translatable="yes">Masked</property>
+ <property name="xalign">0</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="cb_masked_toggled"/>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="descLabelLabel">
+ <widget class="GtkCheckButton" id="installedCheck">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="no_show_all">True</property>
+ <property name="label" translatable="yes">Installed</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;Description:&lt;/b&gt;</property>
- <property name="use_markup">True</property>
- <property name="single_line_mode">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="button_press_event" handler="cb_button_pressed"/>
</widget>
<packing>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
- <property name="y_padding">5</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="overlayLabelLabel">
+ <widget class="GtkLabel" id="homepageLinkLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="no_show_all">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;Overlay:&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;b&gt;Homepage:&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">5</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="descLabel">
+ <widget class="GtkLabel" id="overlayLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="no_show_all">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label</property>
- <property name="wrap">True</property>
+ <property name="single_line_mode">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="overlayLabel">
+ <widget class="GtkLabel" id="descLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="no_show_all">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">label</property>
- <property name="single_line_mode">True</property>
+ <property name="wrap">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="homepageLinkLabel">
+ <widget class="GtkLabel" id="overlayLabelLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="no_show_all">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;Homepage:&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;b&gt;Overlay:&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">5</property>
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="installedCheck">
+ <widget class="GtkLabel" id="descLabelLabel">
<property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes">Installed</property>
<property name="xalign">0</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- <signal name="button_press_event" handler="cb_button_pressed"/>
+ <property name="label" translatable="yes">&lt;b&gt;Description:&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ <property name="single_line_mode">True</property>
</widget>
<packing>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
+ <property name="y_padding">5</property>
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="maskedCheck">
+ <widget class="GtkHBox" id="linkBox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes">Masked</property>
- <property name="xalign">0</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="cb_masked_toggled"/>
+ <property name="spacing">5</property>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="maskedLabel">
+ <widget class="GtkLabel" id="missingLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
+ <property name="no_show_all">True</property>
+ <property name="label" translatable="yes">&lt;span foreground='red'&gt;&lt;b&gt;MISSING KEYWORD&lt;/b&gt;&lt;/span&gt;</property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="testingCheck">
+ <widget class="GtkLabel" id="notInSysLabel">
<property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="no_show_all">True</property>
- <property name="label" translatable="yes">Testing</property>
- <property name="xalign">0</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="cb_testing_toggled"/>
+ <property name="label" translatable="yes">&lt;b&gt;Installed, but not in portage anymore&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="useFlagsLabelLabel">
+ <widget class="GtkLabel" id="licenseLabelLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="no_show_all">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;Use Flags:&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;b&gt;License:&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_padding">5</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="useFlagsLabel">
+ <widget class="GtkLabel" id="licenseLabel">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="no_show_all">True</property>
<property name="xalign">0</property>
- <property name="label">use flags</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
+ <property name="label" translatable="yes">label</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
diff --git a/portato/gui/templates/UpdateWindow.glade b/portato/gui/templates/UpdateWindow.glade
index 4cc678a..2bf712e 100644
--- a/portato/gui/templates/UpdateWindow.glade
+++ b/portato/gui/templates/UpdateWindow.glade
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.1 on Fri Feb 29 00:02:28 2008 -->
+<!--Generated with glade3 3.4.4 on Thu May 15 21:45:30 2008 -->
<glade-interface>
<widget class="GtkWindow" id="UpdateWindow">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="title" translatable="yes">Updateble Packages</property>
+ <property name="title" translatable="yes">Updatable Packages</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="destroy_with_parent">True</property>
<property name="urgency_hint">True</property>
diff --git a/portato/gui/utils.py b/portato/gui/utils.py
index 59210e1..0a2930b 100644
--- a/portato/gui/utils.py
+++ b/portato/gui/utils.py
@@ -204,7 +204,7 @@ class Database (object):
else:
ninst = []
for pkg in self._db[cat]:
- if pkg[2]:
+ if pkg.inst:
yield pkg
else:
ninst.append(pkg)
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 2c9eade..36054a1 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -25,7 +25,7 @@ from ...backend import flags, system # must be the first to avoid circular deps
from ... import get_listener, plugin, dependency
from ...helper import debug, warning, error, info, unique_array
from ...session import Session
-from ...constants import CONFIG_LOCATION, VERSION, APP_ICON
+from ...constants import CONFIG_LOCATION, VERSION, APP_ICON, ICON_DIR
from ...backend.exceptions import PackageNotFoundException, BlockedException
# more GUI stuff
@@ -829,7 +829,7 @@ class MainWindow (Window):
Builds the terminal.
"""
- self.console.set_scrollback_lines(1024)
+ self.console.set_scrollback_lines(2**20)
self.console.set_scroll_on_output(True)
self.console.set_font_from_string(self.cfg.get("consolefont", "GUI"))
self.console.connect("button-press-event", self.cb_right_click)
@@ -1599,8 +1599,10 @@ class MainWindow (Window):
self.emergePaused = cb.get_active()
if not self.emergePaused:
self.queue.continue_emerge()
+ self.tray.set_from_file(APP_ICON)
else:
self.queue.stop_emerge()
+ self.tray.set_from_file(os.path.join(ICON_DIR, "pausing.png"))
# block the handlers of the other buttons
# so that calling "set_active" does not call this callback recursivly
diff --git a/portato/plistener.py b/portato/plistener.py
index 1a5197a..8d35ece 100644
--- a/portato/plistener.py
+++ b/portato/plistener.py
@@ -90,13 +90,7 @@ class PListener (object):
self._sig = None
self._rw = None
else:
- try: # local version
- from _shm import shm_wrapper as shm
- except ImportError:
- try: # version installed together with portato
- from portato._shm import shm_wrapper as shm
- except ImportError: # the normal shm module
- import shm_wrapper as shm
+ import shm_wrapper as shm
self._mem = shm.SharedMemoryHandle(mem)
self._sig = shm.SemaphoreHandle(sig)
diff --git a/portato/plugins/dbus_init.py b/portato/plugins/dbus_init.py
index 851562c..653af31 100644
--- a/portato/plugins/dbus_init.py
+++ b/portato/plugins/dbus_init.py
@@ -1,4 +1,10 @@
-from dbus.mainloop.glib import threads_init
+try:
+ from dbus.mainloop.glib import threads_init
+except ImportError:
+ threads_init = None
+
+from portato.constants import USE_CATAPULT
def dbus_init (*args):
- threads_init()
+ if USE_CATAPULT and threads_init is not None:
+ threads_init()
diff --git a/setup.py b/setup.py
index 112e79f..8c38d45 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@
# File: setup.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2007 René 'Necoro' Neumann
+# Copyright (C) 2006-2008 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -15,124 +15,17 @@ import sys, os, os.path
from distutils.core import setup, Extension
from portato.constants import VERSION, DATA_DIR, ICON_DIR, PLUGIN_DIR, TEMPLATE_DIR
-### copied from shm's setup.py ###
-
-import popen2
-import tempfile
-
-# shm makes use of the ipc_perm structure defined in include/sys/ipc.h (or include/bits/ipc.h
-# on some systems). That structure includes an element called key, _key or __key depending
-# on the OS. Here's the variations I've been able to find with OS version numbers where
-# possible.
-# key: FreeBSD 6, AIX, Solaris, OS X 10.3, OS X 10.4 (conditionally)
-# _key: NetBSD, OS X 10.4 (conditionally)
-# __key: Debian 4 (Etch), Ubuntu 7, RH 3.3 & 3.4
-
-# OS X side note: OS X 10.4's ipc.h (see /Developer/SDKs/MacOSX10.4u.sdk/usr/include/sys/ipc.h)
-# defines structs called __ipc_perm_old (which uses key) and __ipc_perm_new (which uses _key).
-# Use of __ipc_perm_new is inside this:
-# #if defined(__POSIX_C_SOURCE) || defined(kernel) || defined(__LP64__)
-# Obviously __ipc_perm_new is the preferred version. This code doesn't use that yet but
-# will probably do so in some future version when compiled on OS X >= 10.4.
-
-# Trying to enumerate all of the variations is a fool's errand so instead I figure it out
-# on the fly using the function CountKeyUnderscores() below.
-
-# Lots of systems use the unadorned "key" so that's the default when I'm forced to guess.
-COUNT_KEY_UNDERSCORES_DEFAULT = 0
-
-def CountKeyUnderscores():
- """ Uses trial-and-error with the system's C compiler to figure out the number of
- underscores preceding key in the ipc_perm structure. Returns 0, 1 or 2. In case of
- error, it makes a guess and hopes for the best.
- """
- UnderscoresCount = COUNT_KEY_UNDERSCORES_DEFAULT
-
- underscores = { }
-
- # mktemp isn't secure, but I don't care since I use it only for compiling this dummy code.
- # Using mktemp() allows me to keep this code compatible with Python < 2.3.
- path = tempfile.mktemp(dir='.')
- os.mkdir(path)
- if path[-1] != "/": path += '/'
-
- # Here I compile three mini-programs with key, _key and __key. Theoretically,
- # two should fail and one should succeed, and that will tell me how this platform names
- # ipc_perm.key. If the number of successes != 1, something's gone wrong.
- # I use popen2.Popen4() in order to trap (and discard) stderr so that the user doesn't
- # see the compiler errors I'm deliberately generating here.
- src = """
-#include <sys/ipc.h>
-int main(void) { struct ipc_perm foo; foo.%skey = 42; }
-
-"""
- for i in range(0, 3):
- # I'd prefer to feed the C source to the compiler via stdin so as to entirely avoid
- # using files and directories, but I had trouble on Ubuntu getting echo to cooperate.
- filename = "%d.c" % i
- file(path + filename, "w").write(src % ('_' * i))
-
- cmd = ["cc", "-c", "-o", "/dev/null", "%s" % path + filename]
-
- po = popen2.Popen4(cmd)
- if not po.wait(): underscores[i] = True
-
- # Clean up
- os.remove(path + filename)
-
- os.rmdir(path)
-
- KeyCount = len(underscores.keys())
-
- if KeyCount == 1:
- UnderscoresCount = underscores.keys()[0]
- else:
- print """
-*********************************************************************
-* I was unable to detect the structure of ipc_perm on your system. *
-* I'll make my best guess, but compiling might fail anyway. Please *
-* email this message, the error code of %d, and the name of your OS *
-* to the contact at http://NikitaTheSpider.com/python/shm/. *
-*********************************************************************
-""" % KeyCount
-
- return UnderscoresCount
-
-
-MacrosAndDefines = [ ]
-
-# HAVE_UNION_SEMUN needs to be #defined on FreeBSD and OS X and must *not* be #defined
-# on Linux. On other systems, I'm not sure. Please let me know if you find that you
-# need to make changes for your platform.
-if (sys.platform.find("bsd") != -1) or (sys.platform.find("darwin") != -1):
- MacrosAndDefines.append( ('HAVE_UNION_SEMUN', None) )
-
-KeyUnderscores = CountKeyUnderscores()
-
-if KeyUnderscores == 2:
- MacrosAndDefines.append( ('TWO_UNDERSCORE_KEY', None) )
-elif KeyUnderscores == 1:
- MacrosAndDefines.append( ('ONE_UNDERSCORE_KEY', None) )
-else:
- MacrosAndDefines.append( ('ZERO_UNDERSCORE_KEY', None) )
-
-### end copy ###
-
def plugin_list (*args):
"""Creates a list of correct plugin pathes out of the arguments."""
return [("plugins/%s.xml" % x) for x in args]
-packages = ["portato", "portato.gui", "portato.gui.windows", "portato.plugins", "portato.backend", "portato.backend.portage", "portato.backend.catapult", "portato._shm"]
-ext_modules = [Extension("portato._shm.shm", ["_shm/shmmodule.c"], define_macros = MacrosAndDefines, extra_compile_args=["-fPIC"])]
+packages = ["portato", "portato.gui", "portato.gui.windows", "portato.plugins", "portato.backend", "portato.backend.portage"]
data_files = [
(TEMPLATE_DIR, [os.path.join("portato/gui/templates",x) for x in os.listdir("portato/gui/templates") if x.endswith(".glade")]),
(ICON_DIR, ["icons/portato-icon.png"]),
(PLUGIN_DIR, plugin_list("dbus_init")),
(DATA_DIR, ["plugin.xsd"])]
-cmdclass = {}
-package_dir = {"portato._shm" : "_shm"}
-
# do the distutils setup
setup(name="Portato",
version = VERSION,
@@ -142,8 +35,5 @@ setup(name="Portato",
author = "René 'Necoro' Neumann",
author_email = "necoro@necoro.net",
packages = packages,
- data_files = data_files,
- ext_modules = ext_modules,
- cmdclass = cmdclass,
- package_dir = package_dir
+ data_files = data_files
)