Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INIT: The code of pyResMan, pyResMan is a smartcard resource management
tool.
- Loading branch information
1 parent
b52ad13
commit 1001f54
Showing
9 changed files
with
1,131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>pyResMan</name> | |||
<comment></comment> | |||
<projects> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.python.pydev.PyDevBuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.python.pydev.pythonNature</nature> | |||
</natures> | |||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
<?eclipse-pydev version="1.0"?><pydev_project> | |||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | |||
<path>/${PROJECT_DIR_NAME}</path> | |||
</pydev_pathproperty> | |||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> | |||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | |||
</pydev_project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
# -*- coding:utf8 -*- | |||
|
|||
''' | |||
Created on 2015-11-4 | |||
@author: javacardos@gmail.com | |||
@organization: http://www.javacardos.com/ | |||
@copyright: JavaCardOS Technologies. All rights reserved. | |||
''' | |||
|
|||
import wx | |||
from wx.lib.masked.textctrl import BaseMaskedTextCtrl | |||
|
|||
class APDUByteEditCtrl(BaseMaskedTextCtrl): | |||
''' | |||
Edit ctrl for apdu one byte (CLA, INS, P1, P2, LC, LE); | |||
''' | |||
|
|||
def __init__(self, parent, id=-1, value = '', | |||
pos = wx.DefaultPosition, | |||
size = wx.DefaultSize, | |||
style = wx.TE_PROCESS_TAB, | |||
validator = wx.DefaultValidator, | |||
name = 'IpAddrCtrl', | |||
setupEventHandling = True, ## setup event handling by default | |||
bytesCount = 1, | |||
**kwargs): | |||
''' | |||
Constructor | |||
''' | |||
kwargs['mask'] = "XX" * bytesCount | |||
kwargs['excludeChars'] = 'ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ' | |||
BaseMaskedTextCtrl.__init__( | |||
self, parent, id=id, value = value, | |||
pos=pos, size=size, | |||
style = style, | |||
validator = validator, | |||
name = name, | |||
setupEventHandling = setupEventHandling, | |||
**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,39 @@ | |||
# -*- coding:utf8 -*- | |||
|
|||
''' | |||
Created on 2015-10-27 | |||
@author: javacardos@gmail.com | |||
@organization: http://www.javacardos.com/ | |||
@copyright: JavaCardOS Technologies. All rights reserved. | |||
''' | |||
|
|||
import wx | |||
import pyResManDialog | |||
|
|||
class App(wx.App): | |||
''' | |||
The main application class; | |||
''' | |||
def OnInit(self): | |||
''' | |||
Called when application initialize; | |||
''' | |||
|
|||
# Display the main dialog; | |||
dlg = pyResManDialog.pyResManDialog() | |||
dlg.ShowModal() | |||
dlg.Bind(wx.EVT_CLOSE, self.OnDialogClose()) | |||
return True | |||
|
|||
def OnDialogClose(self): | |||
''' | |||
Dialog close event handler; | |||
''' | |||
|
|||
# Exit the app; | |||
wx.Exit() | |||
|
|||
# Create application instance; | |||
app=App() | |||
app.MainLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,66 @@ | |||
# -*- coding:utf8 -*- | |||
|
|||
''' | |||
Created on 2015-10-30 | |||
@author: javacardos@gmail.com | |||
@organization: http://www.javacardos.com/ | |||
@copyright: JavaCardOS Technologies. All rights reserved. | |||
''' | |||
|
|||
class Util(object): | |||
''' | |||
Util functions; | |||
''' | |||
|
|||
HEXCHARS = '0123456789ABCDEFabcdef' | |||
|
|||
@staticmethod | |||
def c2v(c): | |||
"""Get value of one char; Argument c is the input char;""" | |||
cv = ord(c) | |||
if ((cv >= ord('0')) and (cv <= ord('9'))): | |||
return cv - ord('0') | |||
elif ((cv >= ord('A')) and (cv <= ord('F'))): | |||
return cv - ord('A') + 10 | |||
elif ((cv >= ord('a')) and (cv <= ord('f'))): | |||
return cv - ord('a') + 10 | |||
else: | |||
raise ValueError | |||
|
|||
@staticmethod | |||
def s2vl(s): | |||
"""Convert string to value list; Argument s is the input string; ("00A4040000" => {0x00, 0xA4, 0x04, 0x00, 0x00})""" | |||
s = s.replace(' ', '') | |||
s = s.replace('\t', '') | |||
s = s.replace('\r', '') | |||
s = s.replace('\n', '') | |||
if (len(s) & 1) != 0: | |||
raise ValueError() | |||
for c in s: | |||
if c not in Util.HEXCHARS: | |||
raise ValueError() | |||
vl = [] | |||
for i in xrange(0, len(s) / 2): | |||
vl.append(Util.c2v(s[i * 2]) << 4 | Util.c2v(s[i * 2 + 1])) | |||
return vl | |||
|
|||
@staticmethod | |||
def vl2s(vl, pad): | |||
"""Convert value list to string; ({0x00, 0xA4, 0x04, 0x00, 0x00} => "00A4040000")""" | |||
return pad.join("%02X" %(v) for v in vl) | |||
|
|||
@staticmethod | |||
def getTimeStr(tv): | |||
"""Get time string to display; tv is the time value;""" | |||
if tv < 0: | |||
timeStr = '< 0' | |||
elif tv < 0.000001: | |||
timeStr = '%3.3fns' %(tv * (10 ** 9)) | |||
elif tv < 0.001: | |||
timeStr = '%3.3fus' %(tv * (10 ** 6)) | |||
elif tv < 1.0: | |||
timeStr = '%3.3fms' %(tv * (10 ** 3)) | |||
else: | |||
timeStr = '%3.3fs' %(tv * (10 ** 0)) | |||
return timeStr |
Empty file.
Oops, something went wrong.