Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Commit

Permalink
Using code from win-unicode-console to make sure that console is in U…
Browse files Browse the repository at this point in the history
…nicode mode under Windows
  • Loading branch information
rupor-github committed Sep 17, 2016
1 parent e7a530e commit df26a0b
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ Here is brief list of changes:
* Added support for latest Kidle firmware (>= 5.7.2)
* Added simple tool to generate simple thumbnails on Kindle devices

Program uses source code (modified) from following projects released under GPL:
Program uses source code (modified) from following projects released under GPL and MIT licenses:

* [KindleUnpack](https://github.com/kevinhendricks/KindleUnpack)
* [win-unicode-console](https://github.com/Drekin/win-unicode-console)

In order to build [Windows releases](https://github.com/rupor-github/fb2mobi/releases) I am using Python 3.5.2, [this fork](https://bitbucket.org/anthony_tuininga/cx_freeze/pull-requests/87/allow-proper-handling-of-unicode-command/diff) of cx_Freeze 5.0 and following libraries:

Expand Down
9 changes: 9 additions & 0 deletions fb2mobi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
import zipfile
import time
import shutil

import version
from version import WINDOWS

if WINDOWS:
import wincon

from modules.utils import transliterate
from modules.fb2html import Fb2XHTML
Expand Down Expand Up @@ -516,6 +521,10 @@ def process(args):


if __name__ == '__main__':

if WINDOWS:
wincon.enable()

# Настройка парсера аргументов
argparser = argparse.ArgumentParser(
description='Converter of fb2 and epub ebooks to mobi, azw3 and epub formats. Version {0}'.format(
Expand Down
20 changes: 6 additions & 14 deletions synccovers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

import argparse
import version
from version import WINDOWS

if WINDOWS:
import wincon

from modules.mobi_split import mobi_read

Expand Down Expand Up @@ -79,20 +83,8 @@ def process_folder(inputdir, verbose):

if __name__ == '__main__':

if sys.platform == "win32":
class UniStream(object):
__slots__ = ("fileno", "softspace",)

def __init__(self, fileobject):
self.fileno = fileobject.fileno()
self.softspace = False
def write(self, text):
os.write(self.fileno, text.encode("utf-8", errors='ignore'))
def flush(self):
pass

sys.stdout = UniStream(sys.stdout)
sys.stderr = UniStream(sys.stderr)
if WINDOWS:
wincon.enable()

argparser = argparse.ArgumentParser(description='Synchronize covers for side-loaded books on Kindle. Version {0}'.format(version.VERSION))
argparser.add_argument('inputdir', type=str, nargs='?', default=None, help='Directory on mounted device to look for books.')
Expand Down
6 changes: 5 additions & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

import platform

WINDOWS = platform.system().lower() == "windows"

VERSION = u'3.3.1'
Loading

0 comments on commit df26a0b

Please sign in to comment.