Unable to reset admin with python 2.7

Trying to execute reset-admin.sh

root@box:/mnt/raid1/seafile/seafile-server-7.0.4# ./reset-admin.sh
E-mail address: ***
Password:
Password (again):
Traceback (most recent call last):
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/thirdpart/Django-1.11.15-py2.7.egg/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/thirdpart/Django-1.11.15-py2.7.egg/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/thirdpart/Django-1.11.15-py2.7.egg/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/thirdpart/Django-1.11.15-py2.7.egg/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/seahub/base/management/commands/createsuperuser.py", line 150, in handle
    User.objects.create_superuser(email, password)
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/seahub/base/accounts.py", line 71, in create_superuser
    u = self.create_user(email, password, is_staff=True, is_active=True)
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/seahub/base/accounts.py", line 59, in create_user
    user.save()
  File "/mnt/raid1/seafile/seafile-server-7.0.4/seahub/seahub/base/accounts.py", line 329, in save
    if emailuser:
  File "/usr/local/lib/python2.7/dist-packages/future/types/newobject.py", line 70, in __nonzero__
    return type(self).__bool__(self)
AttributeError: type object '_SearpcObj' has no attribute '__bool__'

I think this is a python2.7/python3 bug in libsearpc and getattr method should not return None for bool or other XXX methods.

haiwen/libsearpc/blob/master/pysearpc/client.py#L47
PythonCharmers/python-future/blob/master/src/future/types/newobject.py#L68

Any suggestions how to fix this?

@towa48 Be very wellcome to the Seafile Forum! By the way, thanks a lot por the git pulls requests :slight_smile:

I cannot reproduce at least with 7.0.5:

root@xxxxx /home/seafile/seafile-server-7.0.5 # ./reset-admin.sh
E-mail address: xxxx@xxxx
Password:
Password (again):
Superuser created successfully.

reset%20password

Very strange because libsearpc is not changed
I can fix this by patch future as follow

rm /usr/local/lib/python2.7/dist-packages/future/types/newobject.pyc
nano /usr/local/lib/python2.7/dist-packages/future/types/newobject.py

  def __nonzero__(self):
    try:
      # if hasattr(self, '__bool__'):
      if getattr(self, '__bool__', None) is not None:
          return type(self).__bool__(self)
      # if hasattr(self, '__len__'):
      if getattr(self, '__len__', None) is not None:
          return type(self).__len__(self)
    except:
      return True
    # object has no __nonzero__ method
    return True

Can you check your PYTHON version?
printenv PYTHON or echo $PYTHON
$ python -V

Python 2.7.15+

Same as mine.
The issue same as github .com/google/rekall/issues/312

The fix is

def __getattr__(self, attr):
        if not attr.startswith("__"):
            return obj.NoneObject("Attribute not set")
        raise AttributeError(attr)

I think python 2.7 hasattr method returns true for None value =)

I’m using future 0.16.0

Mine is 0.17.1

root@box:/# ls /usr/local/lib/python2.7/dist-packages/ | grep future
future
future-0.17.1.dist-info
futures-3.3.0.dist-info

try to downgrade

Ok. I can try this later but i don’t think this fix the error, because code the same.
github .com/PythonCharmers/python-future/blob/dd4f27ec99eec1ef9049f93db1176da0ea0d2e84/src/future/types/newobject.py#L86

@jobenvil thanks for your help anyway

Indeed!

Pls, let me know if you need to compare something else more.

@jobenvil Most likely this is libsearpc version.
Build script refers 3.1.0. What version do you have?

LIBSEARPC_VERSION=3.1.0
LIBSEARPC_TAG=v$LIBSEARPC_VERSION

@towa48 Checking the logfiles and output (libsearpc-3.1.0.tar.gz) I have theoretically the same version:

image

but I really have done:

 1101  git reset --hard v3.1-latest
 1102  ./autogen.sh
 1103  ./configure
 1104  make dist

Remark: My libsearpc-3.1.0.tar.gz was compiled at 12. Jul. 2019