Skip to content

szhu/osx-pyutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osx-pyutils

This module contains Python interfaces to some command-line programs that come with Mac OS:

  • osx_keychain uses security to manipulate keychains
  • osx_pboard uses pbcopy and pbpaste to manipulate the clipboard
  • osx_defaults uses defaults to manipulate preferences

Most of these features are also accessible via PyObjC, which takes some time to import. osx-pyutils is designed to be used by shell scripts that live for much shorter than that by working with the already-compiled tools. osx-pyutils can also be used as convenience functions for those who don't want to directly deal with spawning new processes.

This project is currently alpha-quality work and welcomes PRs. Please contribute if you can!

osx_keychain.py

>>> import osx_keychain
>>> d = osx_keychain.Domain('example.com')
>>> d.find_password('interestinglythere')
Traceback (most recent call last):
PasswordNotFoundError: security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
>>> d.add_password('interestinglythere', 'correct horse battery staple')
>>> d.find_password('interestinglythere')
'correct horse battery staple'
>>> d.delete_password('interestinglythere')
>>> d.find_password('interestinglythere')
Traceback (most recent call last):
PasswordNotFoundError: security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

Here's what the result looks like from Keychain Access (before deleting):

screenshot

About

Access certain Mac OS features from Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages