I am trying to access members of an existing Mailman 3 mailing list directly from Django Management console on a Debian Bullseye where Mailman is installed from deb packages (mailman3-full). I can connect to the Django admin console like this (all 3 variants seem to work fine):
$ /usr/share/mailman3-web/manage.py shell
$ mailman-web shell
$ mailman-web shell --settings /etc/mailman3/mailman-web.py
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
>>>
But inside the Django admin console, some mailman components seem to be missing.
I try to access the list manager as described here: Docs > Models > The mailing list manager:
>>> from mailman.interfaces.listmanager import IListManager
>>> from zope.component import getUtility
>>> list_manager = getUtility(IListManager)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass mailman.interfaces.listmanager.IListManager>, '')
Can't figure out why this ComponentLookupError happens.
Also tried to acccess a list with the ListManager implementation:
>>> from mailman.config import config
>>> from mailman.model.listmanager import ListManager
>>> list_manager = ListManager()
>>> list_manager.get('mynews#example.com')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/mailman/database/transaction.py", line 85, in wrapper
return function(args[0], config.db.store, *args[1:], **kws)
AttributeError: 'NoneType' object has no attribute 'store'
>>> list_manager.get_by_list_id('mynews.example.com')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/mailman/database/transaction.py", line 85, in wrapper
return function(args[0], config.db.store, *args[1:], **kws)
AttributeError: 'NoneType' object has no attribute 'store'
What am I doing wrong here? None of the examples in the Mailman 3 models documentation is working if I don't even get that far.
any help greatly appreciated!
It's just the wrong shell you are using. You should use Mailman core shell instead.
It is accessible via just mailman shell in your system most probably.
So mailman shell works great and I could run this interactively:
from mailman.interfaces.listmanager import IListManager
from zope.component import getUtility
from mailman.testing.documentation import dump_list
from operator import attrgetter
def dump_members(roster):
all_addresses = list(member.address for member in roster)
sorted_addresses = sorted(all_addresses, key=attrgetter('email'))
dump_list(sorted_addresses)
list_manager = getUtility(IListManager)
mlist = list_manager.get('ant#example.com')
dump_members(mlist.members.members)
but how could I put this into a script that could be run with mailman withlist -r listmembers -l ant#example.com?
from mailman.testing.documentation import dump_list
from operator import attrgetter
def listmembers(mlist):
roster = mlist.members.members
all_addresses = list(member.address for member in roster)
sorted_addresses = sorted(all_addresses, key=attrgetter('email'))
dump_list(sorted_addresses)
where would I put such a listmembers.py runner? I tried to put it into /usr/lib/python3/dist-packages/mailman/runners directory, but didn't work:
$ mailman withlist -r listmembers -l ant#example.com
ModuleNotFoundError: No module named 'listmembers'
Thanks!
Related
I'm currently trying to get a chatbot running with tensorflow.
The example for the chatbot is from this repository:
Github
I ran into some issues when I tried to run this in my tensorflow docker container.
When starting the script the script exits with an Attribute Error.
Traceback (most recent call last):
File "chatbot.py", line 5, in <module>
import tensorlayer as tl
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/__init__.py", line 47, in <module>
from tensorlayer import initializers
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/initializers.py", line 7, in <module>
from tensorlayer.layers.core import LayersConfig
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/__init__.py", line 12, in <module>
from .activation import *
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/activation.py", line 6, in <module>
from tensorlayer.layers.core import Layer
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/core.py", line 39, in <module>
TF_GRAPHKEYS_VARIABLES = tf.GraphKeys.GLOBAL_VARIABLES
AttributeError: 'module' object has no attribute 'GraphKeys'
I'm using the following Versions:
tensorflow 2.0.0a0
tensorlayer 1.11.1
Maybe some of you had already a similar issue and knows how I could solve this problem.
I solved this problem using pip install tensorflow==1.13.2
Maybe tl mismatch tf, you need to update your tensorlayer to 2.0+.you can use this instruction:
pip3 install https://github.com/tensorlayer/tensorlayer/archive/master.zip
I am trying to implement firebase functions cron job from this link : https://github.com/firebase/functions-cron
Everything worked properly
But when I try to run google cloud cron job it gives me below error :
(/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
I tried this solution : Getting AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS' when running Google Sheets API quickstart
But still no luck.
Can anyone please help me with this.
Issue is with your httplib Module.
When you installed this module for your project you must have installed it with pip for Python 3
If you want to check whether this module is for python 3 or python 2,
Go to httplib2 module and go inside its init.py
later see this line Requires Python 3 or later
if it is written like that means you have installed this library with pip for python 3. Now delete all the httplib2 from your lib folder.
Create a seperate enviroment for python 2.7 and again install all your modules with pip install -t lib -r requirements.txt
I am trying to install Diango via setup up file then it shows the following error:
hari#hari-HP-Pavilion-g6-Notebook-PC:~/Downloads/django-master$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 32, in <module>
version = __import__('django').get_version()
File "/home/hari/Downloads/django-master/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/hari/Downloads/django-master/django/utils/version.py", line 60, in <module>
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
How to fix this error?
Maybe the zip file from github is only for windows, but i see that you are using linux so:
1) Use PIP (Use sudo as you are not inside virtualenv)
sudo pip install Django==1.10.6
2) Use GIT
git clone https://github.com/django/django.git
Hope this help
I have the same problem when install Diango
then I use this in cmd
>>>> import functools
>>> dir(functools)
['WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', '__builtins__', '__doc__', '__file__'
, '__name__', '__package__', 'cmp_to_key', 'partial', 'reduce', 'total_ordering'
, 'update_wrapper', 'wraps']
you can see there is not lru_cache..so, I think this is the reason..
then I installed Python3.6.1
>>> import functools
>>> dir(functools)
['MappingProxyType', 'RLock', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', 'WeakKey
Dictionary', '_CacheInfo', '_HashedSeq', '__all__', '__builtins__', '__cached__'
, '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_
c3_merge', '_c3_mro', '_compose_mro', '_convert', '_find_impl', '_ge_from_gt', '
_ge_from_le', '_ge_from_lt', '_gt_from_ge', '_gt_from_le', '_gt_from_lt', '_le_f
rom_ge', '_le_from_gt', '_le_from_lt', '_lru_cache_wrapper', '_lt_from_ge', '_lt
_from_gt', '_lt_from_le', '_make_key', 'cmp_to_key', 'get_cache_token', 'lru_cache', 'namedtuple', 'partial', 'partialmethod', 'recursive_repr', 'reduce', 'sing
ledispatch', 'total_ordering', 'update_wrapper', 'wraps']
you can see lru_cache there, I wish it's helpful for you (sorry for my English, I'm not good at this..)
When I run the following code, I got an AttributeError:
#!/usr/bin/env python
import threading
import time
def worker():
for i in range(10):
time.sleep(1) # Seconds
print i
threading.Thread(target=worker).start()
Error:
Traceback (most recent call last):
File "/home/yaa110/workspace/Python27/src/threading.py", line 3, in <module>
import threading
File "/home/yaa110/workspace/Python27/src/threading.py", line 11, in <module>
threading.Thread(target=worker).start()
AttributeError: 'module' object has no attribute 'Thread'
I run Python 2.7.5 on Ubuntu 13.10.
Moreover when I use python via terminal, then I got no Error by inputing codes line by line.
It looks like you've created a python file, or module in the current directory of this script which is titled threading or threading.py. This causes your import threading to import the wrong threading library; one where there is no Module named Thread in it!
Rename it and all should be ok. Running the script on my 2.7.2 worked just fine!
I am trying to get boto to work, but I am getting an error.
Installed boto via easy_install, or simply python ./setup.py install
cat boto.py
#!/usr/bin/python
import boto
conn = boto.connect_ec2()
3c075474c10b% ./boto.py
Traceback (most recent call last):
File "./boto.py", line 2, in <module>
import boto
File "/Users/vasiliyb/scripts/boto.py", line 3, in <module>
conn = boto.connect_ec2()
AttributeError: 'module' object has no attribute 'connect_ec2'
Just change the name of your module from "boto.py" to "myboto.py" (or whatever you like) and it will magically work.
You are basically redefining "boto" by naming your module boto.py.