Empty Recycle bin after x Days via Cron script
-
Hi,
as stated above. We want to empty the recycle bin after x Days via cron script automagically. In Zarafa there was an appropriate Python script for doing this.
We found here
https://stash.kopano.io/projects/KSC/repos/core-tools/browse/kopano-cleanup
a script for doing this in Kopano. But the script claims
Traceback (most recent call last):
File “./cleanup.py”, line 8, in <module>
import kopano
ImportError: No module named kopanoWhat is missing here and what can we do?
TIA
Uwe
-
Try installing python3-kopano and then try again.
-
@thctlo said in Empty Recycle bin after x Days via Cron script:
python3-kopano
since the shebang is
# !/usr/bin/env python
its probably ratherpython-kopano
(the python2 variant) that is missing. -
Hmmmhhhhhh ???
***apt-get install python-kopano
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen… Fertig
Einige Pakete konnten nicht installiert werden. Das kann bedeuten, dass
Sie eine unmögliche Situation angefordert haben oder, wenn Sie die
Unstable-Distribution verwenden, dass einige erforderliche Pakete noch
nicht erstellt wurden oder Incoming noch nicht verlassen haben.
Die folgenden Informationen helfen Ihnen vielleicht, die Situation zu lösen:Die folgenden Pakete haben unerfüllte Abhängigkeiten:
python-kopano : Hängt ab von: python-mapi soll aber nicht installiert werden
E: Probleme können nicht korrigiert werden, Sie haben zurückgehaltene defekte Pakete.*** -
@zash1958 you are sadly not sharing which versions you are using. the message you get could have multiple causes. for example because packages in our repo have been updated meanwhile and you local packages would need to be updated (since python-kopano depends on a newer version of python-mapi than you have currently installed).
-
@zash1958 said in Empty Recycle bin after x Days via Cron script:
python-kopano : Hängt ab von: python-mapi soll aber nicht installiert werden
E: Probleme können nicht korrigiert werden, Sie haben zurückgehaltene defekte Pakete.***hmm,
https://github.com/thctlo/Kopano and get the file :
wget -O - https://raw.githubusercontent.com/thctlo/Kopano/master/get-kopano-community.sh | bash
This script pull the community files for your OS and setup a repo so you can use apt-get to install.So get the script, run it, then type :
apt-get -f install
ordpkg-reconfigure -a
-
@thctlo said in Empty Recycle bin after x Days via Cron script:
and setup a repo
his error message above makes it seem that he already has a repository, but he rather has some dependency issues.
-
@fbartels i’ll bet he used dpkg -i *.deb
As far i’ve seen there are not dependency issues atm in kopano.
This at least makes sure all needed packages are available. -
@thctlo said in Empty Recycle bin after x Days via Cron script:
i’ll bet he used dpkg -i *.deb
his logging suggests otherwise:
@zash1958 said in Empty Recycle bin after x Days via Cron script:
apt-get install python-kopano
@thctlo said in Empty Recycle bin after x Days via Cron script:
there are not dependency issues atm in kopano.
my money is on a difference between the already installed packages and the packages currently available from the repository.
-
hmmm… i’ve just tested this. Debian stretch.
python kopano-cleanup.py Traceback (most recent call last): File "kopano-cleanup.py", line 8, in <module> import kopano ImportError: No module named kopano
python3 kopano-cleanup.py Please use: {} --user <username> --days <days> kopano-cleanup.py
chmod +x kopano-cleanup.py ./kopano-cleanup.py ./kopano-cleanup.py: line 5: import: command not found from: can't read /var/mail/datetime ./kopano-cleanup.py: line 7: import: command not found ./kopano-cleanup.py: line 8: import: command not found from: can't read /var/mail/MAPI.Util ./kopano-cleanup.py: line 12: syntax error near unexpected token `(' ./kopano-cleanup.py: line 12: ` def _encode(s):'
I’ll have a better look here.
dpkg -l | grep kopano|grep python ii kopano-python-utils 8.7.80.827.cd49bb60b-0+150.1 amd64 Additional Python-based command-line utils for Kopano Core ii python3-kopano 8.7.80.827.cd49bb60b-0+150.1 all High-level Python 3 bindings for Kopano ii python3-kopano-search 8.7.80.827.cd49bb60b-0+150.1 all Kopano search module for Python 3 ii python3-kopano-utils 8.7.80.827.cd49bb60b-0+150.1 all Kopano utils modules for Python 3
apt-get install python-kopano
and try again …
./kopano-cleanup.py ./kopano-cleanup.py: line 5: import: command not found from: can't read /var/mail/datetime ./kopano-cleanup.py: line 7: import: command not found ./kopano-cleanup.py: line 8: import: command not found from: can't read /var/mail/MAPI.Util ./kopano-cleanup.py: line 12: syntax error near unexpected token `(' ./kopano-cleanup.py: line 12: ` def _encode(s):'
root@mail1:/etc/kopano/bin# python kopano-cleanup.py ('Please use:\n {} --user <username> --days <days> ', 'kopano-cleanup.py')
root@mail1:/etc/kopano/bin# python3 kopano-cleanup.py ('Please use:\n {} --user <username> --days <days> ', 'kopano-cleanup.py')
-
ok found it.
edit kopano-cleanup.py
The fist line :
# !/usr/bin/env python
changed to
#!/usr/bin/env python
just remove the space after #
now after chmod +x , it works with
./kopano-cleanup.py
and, you must install :python-kopano python-mapi
it does not work when only :
python3-kopano python3-mapi
are installed.This is due Debian stretch its default :
ls -al /usr/bin/python lrwxrwxrwx 1 root root 9 Jan 24 2017 /usr/bin/python -> python2.7
But it does work fine, if you dont install
python-kopano python-mapi
and change python to python3 in the first line. -
Thank You!!!
running
python3 ./cleanup.py --user xxx
runs perfectly !