Get working under Windows with http://cheeseshop.python.org/pypi/PyCSC/0.3 (with Python 2.5 for Windows)

Note: you additionally need pycrypto, the source of which you'll get from http://cheeseshop.python.org/pypi/pycrypto/2.0.1
  Compilation of pycrypto can work with cygwin in two steps: python setup.py build -c mingw32 and python setup.py install --skip-build


git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@190 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
hploetz 2007-05-08 09:23:25 +00:00
parent a94d4d8a32
commit 47662ab48e
4 changed files with 47 additions and 5 deletions

View File

@ -1,4 +1,14 @@
import TLV_utils, crypto_utils, utils, pycsc, binascii, fnmatch, sre
try:
import pycsc
except ImportError,e:
try:
import PyCSC
from PyCSC import pycsc # Windows
pycsc.SCARD_PROTOCOL_ANY = PyCSC.SCARD_PROTOCOL_ANY
except ImportError:
raise e # raise the original exception, masking the windows-only attempt
import TLV_utils, crypto_utils, utils, binascii, fnmatch, sre
from utils import C_APDU, R_APDU
DEBUG = True

View File

@ -1,7 +1,17 @@
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
import pycsc, crypto_utils, utils, cards, os, re, binascii, sys, exceptions, traceback, getopt, datetime
try:
import pycsc
except ImportError,e:
try:
import PyCSC
from PyCSC import pycsc # Windows
pycsc.SCARD_PROTOCOL_ANY = PyCSC.SCARD_PROTOCOL_ANY
except ImportError:
raise e # raise the original exception, masking the windows-only attempt
import crypto_utils, utils, cards, os, re, binascii, sys, exceptions, traceback, getopt, datetime
from shell import Shell
def list_readers():

View File

@ -23,7 +23,7 @@ class Shell:
own commands first."""
if sys.modules.has_key("readline"):
histfile = os.path.join(os.environ["HOME"], ".%s.history" % basename)
histfile = os.path.join(self.find_homedir(), ".%s.history" % basename)
try:
readline.read_history_file(histfile)
except IOError:
@ -50,6 +50,18 @@ class Shell:
self.pre_hook = []
self.post_hook = []
self.prompt = ""
def find_homedir(self):
"Returns the home directory of the current user or (in Windows) a directory for application specific data."
if os.environ.has_key("HOME"): return os.environ["HOME"]
elif os.environ.has_key("APPDATA"):
appdata = os.environ["APPDATA"]
dirname = os.path.join(appdata, self.basename)
if not os.path.exists(dirname):
os.mkdir(dirname)
return dirname
else:
raise EnvironmentError, "Can't find a home directory from the environment."
def get_prompt(self):
return self.prompt
@ -81,7 +93,7 @@ class Shell:
lines = []
self.startup_ran = True
try:
fp = file(os.path.join(os.environ["HOME"], ".%src" % self.basename))
fp = file(os.path.join(self.find_homedir(), ".%src" % self.basename))
lines = fp.readlines()
fp.close()
except IOError:

View File

@ -1,4 +1,14 @@
import pycsc, string, binascii, sys, re
try:
import pycsc
except ImportError,e:
try:
import PyCSC
from PyCSC import pycsc # Windows
pycsc.SCARD_PROTOCOL_ANY = PyCSC.SCARD_PROTOCOL_ANY
except ImportError:
raise e # raise the original exception, masking the windows-only attempt
import string, binascii, sys, re
def represent_binary_fancy(len, value, mask = 0):
result = []