Commits

Bertrand Frottier committed 005b729

Moving script code into the lib, adding an entry point for setuptools.

  • Participants
  • Parent commits 3510230

Comments (0)

Files changed (3)

File google_totp

-#! /usr/bin/env python
-import sys
-import base64
-from simpleoath import TOTP
-
-print TOTP(base64.b32decode(sys.argv[-1]))
 #! /usr/bin/env python
 
-from distutils.core import setup
+from setuptools import setup
 
 setup(
     name='simpletotp',
     author_email='Bertrand Frottier <bertrand.frottier@gmail.com>',
     packages=['simpletotp'],
     package_dir={'simpletotp': 'src/simpletotp'},
+    entry_points={'console_scripts': ['google_totp = simpletotp:google_totp']},
 )

File src/simpletotp/__init__.py

         byte_array.insert(0, long_num & 0xff)
         long_num >>= 8
     return byte_array
+
+
+def google_totp():
+    """Simple Google's 2 steps verification code generator.
+    Yield a valid PIN for a given secret key.
+
+    For the moment, the secret key is the last argument given to the sript.
+    """
+    import sys
+    import base64
+
+    print TOTP(base64.b32decode(sys.argv[-1]))