Giter Club home page Giter Club logo

winapps's Introduction

winapps - Python library for managing installed applications on Windows

License PyPI - Python Version PyPI

Installation

To install winapps from PyPI run:

$ pip install winapps

Or clone it using git:

$ git clone https://github.com/rominf/winapps.git
$ cd winapps
$ python(3) setup.py install

Usage

Printing installed applications

import winapps

for app in winapps.list_installed():
    print(app)
# InstalledApplication(name='7-Zip 19.00 (x64)', version='19.00', install_date=None, install_location=WindowsPath('C:/Program Files/7-Zip'), install_source=None, modify_path=None, publisher='Igor Pavlov', uninstall_string='C:\\Program Files\\7-Zip\\Uninstall.exe')
# InstalledApplication(name='Mozilla Firefox 66.0.2 (x64 ru)', version='66.0.2', install_date=None, install_location=WindowsPath('C:/Program Files/Mozilla Firefox'), install_source=None, modify_path=None, publisher='Mozilla', uninstall_string='"C:\\Program Files\\Mozilla Firefox\\uninstall\\helper.exe"')
# InstalledApplication(name='Mozilla Maintenance Service', version='66.0.2', install_date=None, install_location=None, install_source=None, modify_path=None, publisher='Mozilla', uninstall_string='"C:\\Program Files (x86)\\Mozilla Maintenance Service\\uninstall.exe"')
# InstalledApplication(name='Oracle VM VirtualBox Guest Additions 6.0.4', version='6.0.4.0', install_date=None, install_location=None, install_source=None, modify_path=None, publisher='Oracle Corporation', uninstall_string='C:\\Program Files\\Oracle\\VirtualBox Guest Additions\\uninst.exe')
# InstalledApplication(name='Python 3.7.1 (Miniconda3 4.5.12 64-bit)', version='4.5.12', install_date=None, install_location=None, install_source=None, modify_path=None, publisher='Anaconda, Inc.', uninstall_string='"C:\\ProgramData\\Miniconda3\\Uninstall-Miniconda3.exe"')
# InstalledApplication(name='TortoiseHg 4.9.0 (x64)', version='4.9.0', install_date=datetime.date(2019, 4, 3), install_location=WindowsPath('C:/Program Files/TortoiseHg'), install_source=WindowsPath('C:/Users/Roman Inflianskas/Downloads'), modify_path='MsiExec.exe /I{9DF3A4E8-0C61-49CC-9170-79B0DE20EF25}', publisher='Steve Borho and others', uninstall_string='MsiExec.exe /I{9DF3A4E8-0C61-49CC-9170-79B0DE20EF25}')
# ...

Searching applications

import winapps

for app in winapps.search_installed('tortoisehg'):
    print(app)

Uninstalling applications

import winapps

# Assuming you have exactly one installed Notepad++
[npp] = winapps.search_installed('Notepad++')
npp.uninstall('/S')

# Simpler universal variant (uninstall all Notepad++ applications)
winapps.uninstall('Notepad++', args=['/S'])

Caveats

The library currently lookups only for software installed for all users. Only Windows Installer 3.0 .exe installers are supported in installer_command, install, and uninstall are supported.

Credits

This library is heavily inspired by win_pkg SaltStack module.

winapps's People

Contributors

quentiumyt avatar rominf avatar virb30 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

winapps's Issues

Cannot List the Installed Applications and Cannot Uninstall an Application

When I execute the following:

for app.name in winapps.list_installed():
    print(app.name, '\n')

several applications are listed and then I receive this traceback:

  File "<ipython-input-5-057ec1d232d1>", line 1, in <module>
    for app in winapps.search_installed('Notepad++ (32-bit x86)'):

  File "C:\Users\slalo\Miniconda3\lib\site-packages\winapps\__init__.py", line 53, in search_installed
    if not re.search(pattern=pattern, string=str(getattr(app, field_name, '')), flags=search_flags):

  File "C:\Users\slalo\Miniconda3\lib\re.py", line 183, in search
    return _compile(pattern, flags).search(string)

  File "C:\Users\slalo\Miniconda3\lib\re.py", line 286, in _compile
    p = sre_compile.compile(pattern, flags)

  File "C:\Users\slalo\Miniconda3\lib\sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)

  File "C:\Users\slalo\Miniconda3\lib\sre_parse.py", line 930, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)

  File "C:\Users\slalo\Miniconda3\lib\sre_parse.py", line 426, in _parse_sub
    not nested and not items))

  File "C:\Users\slalo\Miniconda3\lib\sre_parse.py", line 654, in _parse
    source.tell() - here + len(this))

error: multiple repeat

Likewise, when I try to directly uninstall an application with this command:

winapps.uninstall('OBS Studio', args=['/S'])

I get this traceback:

  File "<ipython-input-2-d879c8e91f81>", line 1, in <module>
    winapps.uninstall('OBS Studio', args=['/S'])

  File "C:\Users\slalo\Miniconda3\lib\site-packages\winapps\__init__.py", line 72, in uninstall
    app.uninstall(*args)

  File "C:\Users\slalo\Miniconda3\lib\site-packages\winapps\__init__.py", line 36, in uninstall
    command()

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\commands\base.py", line 96, in __call__
    return self.run(args, **kwargs)[1]

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\commands\base.py", line 231, in run
    with self.bgrun(args, **kwargs) as p:

  File "C:\Users\slalo\Miniconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\commands\base.py", line 185, in bgrun
    p = self.popen(args, **kwargs)

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\commands\base.py", line 312, in popen
    return self.cmd.popen(self.args + list(args), **kwargs)

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\machines\local.py", line 131, in popen
    **kwargs)

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\machines\local.py", line 311, in _popen
    **kwargs)  # bufsize = 4096

  File "C:\Users\slalo\Miniconda3\lib\site-packages\plumbum\machines\local.py", line 40, in __init__
    self._proc = Popen(*args, **kwargs)

  File "C:\Users\slalo\Miniconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)

  File "C:\Users\slalo\Miniconda3\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)

  File "C:\Users\slalo\Miniconda3\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)

OSError: [WinError 740] The requested operation requires elevation

Is there any way around these errors or can applications that cause the errors be bypassed?

launch an app

How easy or difficult it is to add a feature to open an installed app?
Can you please add a runbook or a guide to explain the way the code works, that could be useful for others to contribute.

Thanks.

Date Parse Error

Hi,
when using list_installed() on a machine, I get the following error:
ValueError: time data '7/30/2020' does not match format '%Y%m%d'

It is caused by an Adobe program, which has an install date of 7/30/2020 set in registry.

Maybe the date parsing should be wrapped in a try to avoid crashing when the date is corrupt.

TypeError while running basic winapps.list_installed

Was trying the basic documentation and when trying to print apps in iterative way for the below code snippet getting the following error:

import winapps

for app in winapps.list_installed():
    print(app)
Traceback (most recent call last):
  File "C:/<path>/temp.py", line 20, in <module>
    for app in winapps.list_installed():
  File "C:\<path>\venv36\lib\site-packages\winapps\__init__.py", line 42, in <genexpr>
    return (application for application in application_or_none_generator if application is not None)
  File "C:\<path>\venv36\lib\site-packages\winapps\__init__.py", line 41, in <genexpr>
    for application_key in _installed_application_keys())
  File "C:\<path>\venv36\lib\site-packages\winapps\__init__.py", line 186, in _installed_application
    setattr(result, *f(value))
  File "C:\<path>\venv36\lib\site-packages\winapps\__init__.py", line 106, in <lambda>
    'install_date', _none_on_value_not_set(value) and datetime.strptime(value, '%Y%m%d').date()),
TypeError: strptime() argument 1 must be str, not int

Thanks in advance

Release new version

So as it contains some bugfixes, let's have them in a new release.
I don't tested any of the modifications, but i think it is done, rihgt?

File location

Well I really like your script but I'm having a difficult time understanding it
all I want to see is the file location of the program is there a way to do that
rather than showing everything which is quite long in some cases

"""
import winapps

for item in winapps.search_installed('Brother'):
location = item.install_location
print(location)
"""
if there is a way to just show where brother is located at
that would help me tremendously

Fixed dependencies from setup.py

Distutils is built in but doesn't support some arguments.
Importing setuptools at the beginning fixed this issue.

C:\Users\-\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) C:\Users\-\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'extras_require' warnings.warn(msg) C:\Users\-\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg)

Added a try/except in case the user don't have it installed. Fixed in #5 As well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.