kindle manager
This commit is contained in:
17
kman.py
17
kman.py
@@ -61,17 +61,28 @@ books_data =
|
|||||||
SYS = 'WIN' if platform.system()=='Windows' else \
|
SYS = 'WIN' if platform.system()=='Windows' else \
|
||||||
('LINUX' if platform.system()=='LINUX' else 'MAC')
|
('LINUX' if platform.system()=='LINUX' else 'MAC')
|
||||||
|
|
||||||
|
frozen = 'not'
|
||||||
|
#CURRPATH = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||||
|
CURRPATH = ''
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
# we are running in a bundle
|
||||||
|
frozen = 'ever so'
|
||||||
|
CURRPATH = sys._MEIPASS
|
||||||
|
os.chdir(CURRPATH)
|
||||||
|
else:
|
||||||
|
# we are running in a normal Python environment
|
||||||
|
CURRPATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
# some constants
|
# some constants
|
||||||
LASTLINE = '=========='
|
LASTLINE = '=========='
|
||||||
NTPREF = '--CG注:'
|
NTPREF = '--CG注:'
|
||||||
CLIPFN = 'My Clippings.txt'
|
CLIPFN = 'My Clippings.txt'
|
||||||
WORDFN = 'vocab.db'
|
WORDFN = 'vocab.db'
|
||||||
CURRPATH = os.path.dirname(os.path.realpath(sys.argv[0]))
|
|
||||||
OUTPREF = os.path.join(CURRPATH,'CLIP')
|
OUTPREF = os.path.join(CURRPATH,'CLIP')
|
||||||
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
||||||
LOG2FILE = 1 # 0 - to stdio; 1 - to file
|
LOG2FILE = 1 # 0 - to stdio; 1 - to file
|
||||||
LOGFILE = 'log'
|
|
||||||
DELIMITER= '|'
|
DELIMITER= '|'
|
||||||
|
LOGFILE = os.path.join(CURRPATH,'log')
|
||||||
BACKUPFOLDER = os.path.join(CURRPATH,'backup')
|
BACKUPFOLDER = os.path.join(CURRPATH,'backup')
|
||||||
BACKUPNOTEFN = os.path.join(BACKUPFOLDER,'bk.note.data') # kindle notes
|
BACKUPNOTEFN = os.path.join(BACKUPFOLDER,'bk.note.data') # kindle notes
|
||||||
BACKUPWORDFN = os.path.join(BACKUPFOLDER,'bk.word.data') # kindle words
|
BACKUPWORDFN = os.path.join(BACKUPFOLDER,'bk.word.data') # kindle words
|
||||||
@@ -834,7 +845,7 @@ if __name__=='__main__':
|
|||||||
km.add_note_to_highlight(books)
|
km.add_note_to_highlight(books)
|
||||||
|
|
||||||
# test dict json convert
|
# test dict json convert
|
||||||
with open(os.path.join(CURRPATH,'xx', 'w'), encoding='utf8', errors='ignore') as fw:
|
with open(os.path.join(CURRPATH,'xx'), 'w', encoding='utf8', errors='ignore') as fw:
|
||||||
fw.write(km.dict2json(books))
|
fw.write(km.dict2json(books))
|
||||||
if km.json2dict(os.path.join(CURRPATH,'xx'))==books: print( 'test OK')
|
if km.json2dict(os.path.join(CURRPATH,'xx'))==books: print( 'test OK')
|
||||||
|
|
||||||
|
|||||||
19
kmanapp.py
19
kmanapp.py
@@ -867,6 +867,21 @@ class nTableModel(QAbstractTableModel):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
"""
|
||||||
|
frozen = 'not'
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
# we are running in a bundle
|
||||||
|
frozen = 'ever so'
|
||||||
|
bundle_dir = sys._MEIPASS
|
||||||
|
else:
|
||||||
|
# we are running in a normal Python environment
|
||||||
|
bundle_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
print( 'we are',frozen,'frozen')
|
||||||
|
print( 'bundle dir is', bundle_dir )
|
||||||
|
print( 'sys.argv[0] is', sys.argv[0] )
|
||||||
|
print( 'sys.executable is', sys.executable )
|
||||||
|
print( 'os.getcwd is', os.getcwd() )
|
||||||
|
|
||||||
print('sys.path[0]', sys.path[0])
|
print('sys.path[0]', sys.path[0])
|
||||||
print('sys.argv[0]', sys.argv[0])
|
print('sys.argv[0]', sys.argv[0])
|
||||||
print('os.path.realpath(sys.executable)', os.path.realpath(sys.executable))
|
print('os.path.realpath(sys.executable)', os.path.realpath(sys.executable))
|
||||||
@@ -875,8 +890,11 @@ if __name__ == "__main__":
|
|||||||
os.path.dirname(os.path.realpath(sys.executable)))
|
os.path.dirname(os.path.realpath(sys.executable)))
|
||||||
print('os.path.dirname(os.path.realpath(sys.argv[0]))',
|
print('os.path.dirname(os.path.realpath(sys.argv[0]))',
|
||||||
os.path.dirname(os.path.realpath(sys.argv[0])))
|
os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||||
|
print('os.path.dirname(os.path.abspath(__file__))',
|
||||||
|
os.path.dirname(os.path.abspath(__file__)))
|
||||||
util = Util()
|
util = Util()
|
||||||
print('get_app_path',util.get_app_path())
|
print('get_app_path',util.get_app_path())
|
||||||
|
"""
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
kmw = kmanWindow()
|
kmw = kmanWindow()
|
||||||
@@ -912,4 +930,5 @@ if __name__ == "__main__":
|
|||||||
print ("Error: can not start thread")
|
print ("Error: can not start thread")
|
||||||
"""
|
"""
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
#sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.11.2, 2020-06-25T21:57:36. -->
|
<!-- Written by QtCreator 4.11.2, 2020-06-29T09:50:04. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
@@ -54,7 +54,5 @@
|
|||||||
<file>icons/book.png</file>
|
<file>icons/book.png</file>
|
||||||
<file>icons/amazon.png</file>
|
<file>icons/amazon.png</file>
|
||||||
<file>icons/flower.png</file>
|
<file>icons/flower.png</file>
|
||||||
<file>kmanapp.ico</file>
|
|
||||||
<file>kmanapp.png</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|
||||||
|
|
||||||
a = Analysis(['kmanapp.py'],
|
a = Analysis(['kman.py', 'kmanapp.py', 'kmanapp_rc.py', 'mainwindow.py', 'mtable.py', 'parseweb.py', ],
|
||||||
pathex=['/Users/mark/kman'],
|
pathex=['/Users/mark/kman'],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[],
|
datas=[],
|
||||||
|
|||||||
2174
kmanapp_rc.py
2174
kmanapp_rc.py
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,8 @@ A: rm -fr __pycache__, 重新打包
|
|||||||
1. (kmanenv) [gavin@gavin-2 kman]$Release/kmanapp.app/Contents/MacOS/kmanapp
|
1. (kmanenv) [gavin@gavin-2 kman]$Release/kmanapp.app/Contents/MacOS/kmanapp
|
||||||
NameError: name 'kMan' is not defined
|
NameError: name 'kMan' is not defined
|
||||||
A: pathex=['/Users/mark/penv/kman',]
|
A: pathex=['/Users/mark/penv/kman',]
|
||||||
|
Analysis(['kmanapp.py'], ==>
|
||||||
|
Analysis(['kman.py', 'kmanapp.py', 'kmanapp_rc.py', 'mainwindow.py', 'mtable.py', 'parseweb.py', ],
|
||||||
|
|
||||||
|
|
||||||
# reference
|
# reference
|
||||||
|
|||||||
Reference in New Issue
Block a user