%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/old/usr/bin/
Upload File :
Create Path :
Current File : //data/old/usr/bin/calibre-uninstall

#!/usr/bin/python
from __future__ import print_function, unicode_literals
euid = 0

import os, subprocess, shutil

try:
    raw_input
except NameError:
    raw_input = input

if os.geteuid() != euid:
    print ('The installer was last run as user id:', euid, 'To remove all files you must run the uninstaller as the same user')
    if raw_input('Proceed anyway? [y/n]:').lower() != 'y':
        raise SystemExit(1)

frozen_path = '/opt/calibre'
if not frozen_path or not os.path.exists(os.path.join(frozen_path, 'resources', 'calibre-mimetypes.xml')):
    frozen_path = None

for f in []:
    cmd = ['xdg-mime', 'uninstall', f]
    print ('Removing mime resource:', os.path.basename(f))
    ret = subprocess.call(cmd, shell=False)
    if ret != 0:
        print ('WARNING: Failed to remove mime resource', f)

for x in tuple(['/usr/bin/calibre-customize', '/usr/bin/ebook-viewer', '/usr/bin/calibre-debug', '/usr/bin/calibre-parallel', '/usr/bin/calibre', '/usr/bin/ebook-meta', '/usr/bin/lrfviewer', '/usr/bin/ebook-polish', '/usr/bin/web2disk', '/usr/bin/ebook-convert', '/usr/bin/ebook-device', '/usr/bin/calibre-smtp', '/usr/bin/calibredb', '/usr/bin/lrf2lrs', '/usr/bin/ebook-edit', '/usr/bin/calibre-server', '/usr/bin/fetch-ebook-metadata', '/usr/bin/lrs2lrf', '/usr/bin/markdown-calibre', '/usr/share/zsh/site-functions/_calibre', '/usr/share/bash-completion/completions/calibre']) + tuple([]) + (os.path.abspath(__file__), __file__, frozen_path):
    if not x or not os.path.exists(x):
        continue
    print ('Removing', x)
    try:
        if os.path.isdir(x):
            shutil.rmtree(x)
        else:
            os.unlink(x)
    except Exception as e:
        print ('Failed to delete', x)
        print ('	', e)

icr = []
mimetype_icons = []

def remove_icon(context, name, size, update=False):
    cmd = ['xdg-icon-resource', 'uninstall', '--context', context, '--size', size, name]
    if not update:
        cmd.insert(2, '--noupdate')
    print ('Removing icon:', name, 'from context:', context, 'at size:', size)
    ret = subprocess.call(cmd, shell=False)
    if ret != 0:
        print ('WARNING: Failed to remove icon', name)

for i, (context, name, size) in enumerate(icr):
    if context == 'mimetypes':
        mimetype_icons.append((name, size))
        continue
    remove_icon(context, name, size, update=i == len(icr) - 1)

mr = []
for f in mr:
    cmd = ['xdg-desktop-menu', 'uninstall', f]
    print ('Removing desktop file:', f)
    ret = subprocess.call(cmd, shell=False)
    if ret != 0:
        print ('WARNING: Failed to remove menu item', f)

print ()

if mimetype_icons and raw_input('Remove the ebook format icons? [y/n]:').lower() in ['', 'y']:
    for i, (name, size) in enumerate(mimetype_icons):
        remove_icon('mimetypes', name, size, update=i == len(mimetype_icons) - 1)

Zerion Mini Shell 1.0