Re: How to get the current set LOG_MASK in Python's syslog module?

2022-09-22 Thread Richard Moseley
According to documentation syslog.setlogmask returns the current mask so
save the value to reset later on.

Oldval = syslog.setlogmask(newmask)

This sets oldval to original mask.

On Thu, 22 Sep 2022, 14:32 ,  wrote:

> X-Post: https://stackoverflow.com/q/73814924/4865723
>
> Hello,
>
> I'm aware that there is a `logging` package that is more _modern_ then
> [`syslog`](https://docs.python.org/3/library/syslog.html). But I have
> old code here to deal with that does use `syslog`. So that question is
> specific to `syslog` and not to `logging`.
>
> I would like to get the current `LOG_MASK`, which is kind of a logging
> level. According to the docu it seems that `syslog` doesn't have a
> mechanism for that.
>
> Does someone has an idea?
>
> The docu also tells me that `syslog` does let pass all messages by
> default.
> My point is I do manipulate via `syslog.setlogmask()` the current log
> leve. At the end I would like to set it back to its previous value.
>
> Kind
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing python3 packages using pip

2019-08-08 Thread Richard Moseley
You will need to have to install python3-pip (or equivalent on your
repository) to install the version of pip suitable for use with python 3.x.
The program is usually installed as 'pip3' so substitute 'pip' for 'pip3'
to install or upgrade Pypy packages.
Of course, if possible always create a new 'venv' and install the packages
in there instead of the system, it avoids polluting the environment and
makes it easier to tidy up unwanted packages at a later stage.

Hope this helps, Richard Moseley.


On Thu, 8 Aug 2019 at 16:03, Rich Shepard  wrote:

> The host has Python3-3.7.4 installed. Trying to use "pip install numpy3"
> fails:
>
> # pip install numpy3
> DEPRECATION: Python 2.7 will reach the end of its life on January 1st,
> 2020.
> Please upgrade your Python as Python 2.7 won't be maintained after that
> date. A future version of pip will drop support for Python 2.7. More
> details
> about Python 2 support in pip, can be found at
> https://pip.pypa.io/en/latest/development/release-process/#python-2-support
>
> Collecting numpy3
>ERROR: Could not find a version that satisfies the requirement numpy3
> (from versions: none)
> ERROR: No matching distribution found for numpy3
>
> How do I install numpy3, python3-matplotlib, and scipy3 using PIP?
>
> Rich
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot get any Python commands to work

2017-06-12 Thread Richard Moseley
I believe that you need to be using this as a command rather a module from
within python, in other words try executing easy_install from the command
line, or try using pip which is now preferred method of installing new
third-party packages. You may need to add '-3.6' or '-36' if you have
multiple versions installed.

On 12 June 2017 at 15:47, David Marquand  wrote:

> I am trying to learn Django and cannot get easy_install to work. Python
> working on PyDev fine.
>
>
>
>
>
>
>
>
> PS C:\Windows\system32> python
> Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit
> (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> easy_install --version
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'easy_install' is not defined
> >>> python
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'python' is not defined
> >>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Namedtuple problem #32.11.d

2017-06-06 Thread Richard Moseley

On 06/06/17 13:29, Neil Cerutti wrote:

On 2017-06-06, Deborah Swanson  wrote:

I have a list of namedtuples:

[{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='')
. . .
{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='')]

In the first section of code, I process some of the first 10
columns (r0=v0, r1=v1,...,r10=v10), and place the results in
blank columns, also in the first 10 columns.

I too have sometimes started with a namedtuple and then found I
needed to make changes to the records. I typically abandon
namedtuple at this point, after only one bad experience trying to
work around my choice of container.

In a package that I'm working on that enables access natively to legacy 
C-ISAM files, I've found that I need to create a form of a namedtuple 
that makes use of descriptors to access each of the fields within a 
record using attribute lookup, but to also create the record object at 
runtime using a description of the fields read from another file (C-ISAM 
works by using offsets within a record and does not natively store a 
mapping between name and offset). I found that using a metaclass to 
store the fields in a OrderedDict enabled me to embed a namedtuple to 
return the record back to the rest of the package. The code can be found 
in pyisam/table/record.py from http://github.com/rpmoseley/pyisam.git. 
The code is written for 3.x but the code path for versions before 3.6 
should work for 2.7.


--
https://mail.python.org/mailman/listinfo/python-list


Test to see if message is bounced

2017-06-01 Thread Richard Moseley
Apologies if this appears on the list, but I'm checking whether I have been
placed onto a blacklist since previous postings have been bounced back with
an error that the email address is not on the "subscribers list". I
previously had an email address of "dickie.mose...@virgin.net" which has
now been deactivated.

Richard Moseley
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue15448] utimes() functions fail with ENOSYS even when detected by configure

2012-07-25 Thread Richard Moseley

New submission from Richard Moseley dickie.mose...@virgin.net:

When building on a ASUS Eee PC 1000 running the original Xandros O/S with 
libc-2.7-13, the various utimes() functions are being detected as available for 
use, everything compiles. However, during installation of the lib-dynload 
libraries, the error 'Error: Function not implemented' is given and the 
installation halts.

This problem has been tracked down to the fact that some of the utimes() 
functions will return ENOSYS rather than the expected result.

I have now patched the configure.ac script to check for the seven variants of 
the function, which is attached. This patch would ideally have made use of the 
same model as the AC_CHCEK_FUNCS macro but this would require adding a new file 
to the source tree.

--
components: Build
files: configure.ac.diff
keywords: patch
messages: 166413
nosy: richmose
priority: normal
severity: normal
status: open
title: utimes() functions fail with ENOSYS even when detected by configure
type: compile error
versions: Python 3.3
Added file: http://bugs.python.org/file26514/configure.ac.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15448
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Incorrect detection of futimesns/futimes in 3.3.0b1

2012-07-19 Thread RICHARD MOSELEY
I have recently been compiling the source for 3.3.0 beta1 and have
discovered that even though the functions futimens, futimes and lutimes are
found by the configure script, since they exist as entry points in libc,
their actually only stub functions that simply return ENOSYS (Not
Implemented) when called.

This causes the installation stage to fail with a fatal error, 'Error:
Function Not Implemented', during the installation of the libraries into
the lib-dynload directory, leading me to initially think that there was a
problem with the distutils module (fairly unlikely I know).

The platform I am compiling on, is an ASUS Eee PC 1000 running the original
Xandros operating system.

I can make the installation complete, by modifying the pyconfig.h and
undefining the erroneous defines: HAVE_FUNC_FUTIMENS, HAVE_FUNC_FUTIMES and
HAVE_FUNC_LUTIMES.

I am now considering providing a general patch to the configure.ac file
which will more correctly detect all the various flavours of utimes
(futimens, futimes, lutimes, futimesat, utimensat and utimes) using a
different check other than AC_CHECK_FUNCS. Or would it be better simply to
keep it private and apply the fix each time I upgrade the source code to
the latest version?

Richard Moseley
-- 
http://mail.python.org/mailman/listinfo/python-list


Use of internal ctypes objects

2012-06-15 Thread RICHARD MOSELEY
I have a module which makes use of ctypes to interface to the IBM C-ISAM
library under linux. I have created a libpyisam.so library which combines
the two official libraries, libifisam.so and libifisamx.so and provides a
SONAME for the ctypes module (if that is still required).

My main object uses a dictionary in which the keys are the external
functions that can be called from the externl library, and the values are
initially tuples which define the arguments and return type for the
functions. The first time that a function is called, the __getattr__
function locates the function in the library then modifies the return type
and arguments according to the tuple stored in the value, this object is
then stored in place of the tuple so that subsequent calls simply use the
previous object.

To check whether the function has been previously converted, I make use of
internal objects within the ctypes module, namely, _SimpleCData and
_CFuncPtr. Is this a safe thing to do, bearing in mind that the objects are
documentated as internal?

In order to make the above paragraphs clear, I provide a cutdown version of
the object in question with a sample of the functions and the calling
convention used. Is there a better way to do this using ctypes:

from ctypes import *

class ISAMobject(dict):
  
  The _func dictionary initially consists of:
(args,...)where the return type is c_int and arguments
are passed,
(None,) where the return type is c_int but no arguments
are passed,
(ret,(args,...))where the return type is not c_int and
arguments are passed,
(ret,None) where the return type is not c_int and no
arguments are passed,
None where there is no return type and no arguments
are passed
  
  _func = {
'isbegin'  : (None,),
'iscluster' : (c_int, byref(keydesc)),
'islangchk' : None,
'islanginfo' : (c_char_p, (c_char_p,))
  }

  _const = {
'iserrno' : c_int,
'iscopyright' : c_char_p
  }

  _lib = cdll.LoadLibrary('./libpyisam.so')

  def __getattr__(self, name):
func_info = self._func.get(name, 'NONE')
if func_info == 'NONE':
   const_info = self._const.get(name, 'NONE')
   if const_info == 'NONE':
  raise AttributeError('Underlying ISAM library does not have %s
attribute' % name)
   if not isinstance(const_info, ctypes._SimpleCData):
  const_info = const_info.in_dll(self._lib, name)
  self._const[name] = const_info
   return const_info.value if hasattr(const_info, 'value') else
const_info
elif not instance(func_info, ctypes._CFuncPtr):
   real_func = getattr(self._lib, name)
   if real_func is None:
  raise AttributeError('Underlying ISAM library does not support %s
function' % name)
   if func_info is None:
  real_func.restype = real.argtypes = None
   elif isinstance(func_info, list):
  real_func.restype, real_func.argtypes = func_info
   elif len(func_info)  1 and isinstance(func_info[1], tuple):
  real_func.restype, real_func.argtypes = func_info
   elif isinstance(func_info, tuple):
  real_func.argtypes = func_info
   else:
  real_func.restype = func_info
   self._func[name] = func_info = real_func
return func_info

Thank you in advance,
Richard Moseley
-- 
http://mail.python.org/mailman/listinfo/python-list