diff --git a/CHANGELOG.md b/CHANGELOG.md index 10d1c82..2ce2fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### py-kms_2020-07-01 +- py-kms Gui: now matches all cli options, added modes onlyserver / onlyclient, + added some animations. +- Added suboptions FILEOFF and STDOUTOFF of -F. +- Created option for asynchronous messages. +- Cleaned options parsing process. + ### py-kms_2020-02-02 - Optimized pretty-print messages process. - Added -F FILESTDOUT option. diff --git a/LICENSE.gui.md b/LICENSE.gui.md new file mode 100644 index 0000000..1d06073 --- /dev/null +++ b/LICENSE.gui.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Matteo ℱan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f1c4275..215dd2d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ _py-kms_ is a port of node-kms created by [cyrozap](http://forums.mydigitallife. - Windows 7 - Windows 8 - Windows 8.1 - - Windows 10 ( 1511 / 1607 / 1703 / 1709 / 1803 / 1809 / 1903 / 1909 ) + - Windows 10 ( 1511 / 1607 / 1703 / 1709 / 1803 / 1809 ) + - Windows 10 ( 1903 / 1909 / 20H1 ) - Windows Server 2008 - Windows Server 2008 R2 - Windows Server 2012 @@ -44,20 +45,26 @@ _py-kms_ is a port of node-kms created by [cyrozap](http://forums.mydigitallife. - To show the help pages type: `python pykms_Server.py -h` and `python pykms_Client.py -h`. - To generate a random HWID use `-w` option: `python pykms_Server.py -w RANDOM`. - To get the HWID from any server use the client, for example type: `python pykms_Client.py 0.0.0.0 1688 -m Windows8.1 -V INFO`. + +- To change your logfile path use `-F` option, for example: `python pykms_Server.py -F /path/to/your/logfile.log -V DEBUG`. - To view a minimal set of logging information use `-V MINI` option, for example: `python pykms_Server.py -F /path/to/your/logfile.log -V MINI`. - To redirect logging on stdout use `-F STDOUT` option, for example: `python pykms_Server.py -F STDOUT -V DEBUG`. - You can create logfile and view logging information on stdout at the same time with `-F FILESTDOUT` option, for example: `python pykms_Server.py -F FILESTDOUT /path/to/your/logfile.log -V DEBUG`. -- Select timeout (seconds) for py-kms with `-t` option, for example `python pykms_Server.py -t 10` +- With `-F STDOUTOFF` you disable all stdout messages (but a logfile will be created), for example: `python pykms_Server.py -F STDOUTOFF /path/to/your/logfile.log -V DEBUG`. +- With `-F FILEOFF` you disable logfile creation. + +- Select timeout (seconds) for py-kms with `-t0` option, for example `python pykms_Server.py -t0 10`. +- Option `-y` enables printing asynchronously of messages (pretty / logging). - For launching py-kms GUI make executable `pykms_Server.py` file with `chmod +x /path/to/folder/py-kms/pykms_Server.py`, then simply run `pykms_Server.py` double-clicking. -- You can run py-kms deamonized (via [Etrigan](https://github.com/SystemRage/Etrigan)) using a command like: `python pykms_Server.py etrigan start` and stop it with: `python pykms_Server.py etrigan stop`. +- You can run py-kms daemonized (via [Etrigan](https://github.com/SystemRage/Etrigan)) using a command like: `python pykms_Server.py etrigan start` and stop it with: `python pykms_Server.py etrigan stop`. - With Etrigan you have another way to launch py-kms GUI (specially suitable if you're using a virtualenv), so: `python pykms_Server.py etrigan start -g` -and stop the GUI with the same precedent command (or interact with EXIT button). +and stop the GUI with `python pykms_Server.py etrigan stop` (or interact with the EXIT button). # Docker ![auto-docker](https://img.shields.io/docker/cloud/automated/pykmsorg/py-kms) ![status-docker](https://img.shields.io/docker/cloud/build/pykmsorg/py-kms) -This projects has docker image support. You can find all available image configurations inside the docker folder. +This project has docker image support. You can find all available image configurations inside the docker folder. There are three tags of the images available: * `latest`, currently the same like minimal... * `minimal`, wich is based on the python3 minimal configuration of py-kms. _This image does NOT include SQLLite support!_ @@ -70,4 +77,5 @@ To ensure that the image is always up-to-date you should check [watchtower](http Consult the [Wiki](https://github.com/SystemRage/py-kms/wiki) for more information about activation with _py-kms_ and to get GVLK keys. # License - [![License](https://img.shields.io/badge/license-unlicense-lightgray.svg)](https://github.com/SystemRage/py-kms/blob/master/LICENSE) + _py-kms_ is [![License0](https://img.shields.io/badge/license-unlicense-lightgray.svg)](https://github.com/SystemRage/py-kms/blob/master/LICENSE) + _py-kms GUI_ is [![License1](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/SystemRage/py-kms/blob/master/LICENSE.gui.md) © Matteo ℱan diff --git a/docker/README.md b/docker/README.md index 8e877c6..de75506 100644 --- a/docker/README.md +++ b/docker/README.md @@ -15,7 +15,7 @@ docker run -it -d --name py3-kms \ --restart unless-stopped pykmsorg/py-kms:[TAG] ``` _Make sure to insert at `[TAG]` your wanted edition! The default is `latest`, which does not include SQLLite support. For all available tag check [this](https://hub.docker.com/r/pykmsorg/py-kms/tags) out._ -Please note you can omit the `SQLITE` option if you plan to use the minimal ot `latest` image +Therefore you can omit the `-e SQLITE=...` and `-p 8080:8080` option if you plan to use the `minimal` or `latest` image. # Sqlite-web A web-based SQLite database browser written in Python. diff --git a/py-kms/Etrigan.py b/py-kms/Etrigan.py index 1d90a53..fd0571e 100644 --- a/py-kms/Etrigan.py +++ b/py-kms/Etrigan.py @@ -592,8 +592,8 @@ def main(): parser = Etrigan_parser() args = vars(parser.parse_args()) # Check arguments. - Etrigan_check().checkfile(args['etriganpid'], 'pidfile', '.pid') - Etrigan_check().checkfile(args['etriganlog'], 'pidfile', '.log') + Etrigan_check().checkfile(args['etriganpid'], '--etrigan-pid', '.pid') + Etrigan_check().checkfile(args['etriganlog'], '--etrigan-log', '.log') # Setup daemon. jasonblood_1 = Etrigan(pidfile = args['etriganpid'], logfile = args['etriganlog'], loglevel = args['etriganlev'], diff --git a/py-kms/graphics/pykms_Arrow_Left.gif b/py-kms/graphics/pykms_Arrow_Left.gif new file mode 100644 index 0000000..731405d Binary files /dev/null and b/py-kms/graphics/pykms_Arrow_Left.gif differ diff --git a/py-kms/graphics/pykms_Arrow_Right.gif b/py-kms/graphics/pykms_Arrow_Right.gif new file mode 100644 index 0000000..422583f Binary files /dev/null and b/py-kms/graphics/pykms_Arrow_Right.gif differ diff --git a/py-kms/graphics/pykms_Keyhole_Left.gif b/py-kms/graphics/pykms_Keyhole_Left.gif new file mode 100644 index 0000000..5d2933c Binary files /dev/null and b/py-kms/graphics/pykms_Keyhole_Left.gif differ diff --git a/py-kms/graphics/pykms_Keyhole_Right.gif b/py-kms/graphics/pykms_Keyhole_Right.gif new file mode 100644 index 0000000..d7499bb Binary files /dev/null and b/py-kms/graphics/pykms_Keyhole_Right.gif differ diff --git a/py-kms/pykms_Keys.gif b/py-kms/graphics/pykms_Keys.gif similarity index 100% rename from py-kms/pykms_Keys.gif rename to py-kms/graphics/pykms_Keys.gif diff --git a/py-kms/pykms_Base.py b/py-kms/pykms_Base.py index 15c4ff9..a20edb0 100644 --- a/py-kms/pykms_Base.py +++ b/py-kms/pykms_Base.py @@ -140,21 +140,21 @@ class kmsBase: # https://docs.microsoft.com/en-us/windows/deployment/volume-activation/activate-windows-10-clients-vamt MinClients = kmsRequest['requiredClientCount'] RequiredClients = MinClients * 2 - if self.srv_config["CurrentClientCount"] != None: - if 0 < self.srv_config["CurrentClientCount"] < MinClients: + if self.srv_config["clientcount"] != None: + if 0 < self.srv_config["clientcount"] < MinClients: # fixed to 6 (product server) or 26 (product desktop) currentClientCount = MinClients + 1 pretty_printer(log_obj = loggersrv.warning, put_text = "{reverse}{yellow}{bold}Not enough clients ! Fixed with %s, but activated client \ could be detected as not genuine !{end}" %currentClientCount) - elif MinClients <= self.srv_config["CurrentClientCount"] < RequiredClients: - currentClientCount = self.srv_config["CurrentClientCount"] + elif MinClients <= self.srv_config["clientcount"] < RequiredClients: + currentClientCount = self.srv_config["clientcount"] pretty_printer(log_obj = loggersrv.warning, put_text = "{reverse}{yellow}{bold}With count = %s, activated client could be detected as not genuine !{end}" %currentClientCount) - elif self.srv_config["CurrentClientCount"] >= RequiredClients: + elif self.srv_config["clientcount"] >= RequiredClients: # fixed to 10 (product server) or 50 (product desktop) currentClientCount = RequiredClients - if self.srv_config["CurrentClientCount"] > RequiredClients: + if self.srv_config["clientcount"] > RequiredClients: pretty_printer(log_obj = loggersrv.warning, put_text = "{reverse}{yellow}{bold}Too many clients ! Fixed with %s{end}" %currentClientCount) else: @@ -230,8 +230,8 @@ could be detected as not genuine !{end}" %currentClientCount) # rule: timeserver - 4h <= timeclient <= timeserver + 4h, check if is satisfied. response['responseTime'] = kmsRequest['requestTime'] response['currentClientCount'] = currentClientCount - response['vLActivationInterval'] = self.srv_config["VLActivationInterval"] - response['vLRenewalInterval'] = self.srv_config["VLRenewalInterval"] + response['vLActivationInterval'] = self.srv_config["activation"] + response['vLRenewalInterval'] = self.srv_config["renewal"] if self.srv_config['sqlite'] and self.srv_config['dbSupport']: response = sql_update_epid(self.dbName, kmsRequest, response) diff --git a/py-kms/pykms_Client.py b/py-kms/pykms_Client.py index 9dbe4ef..09f6f56 100644 --- a/py-kms/pykms_Client.py +++ b/py-kms/pykms_Client.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- import re import binascii @@ -21,11 +22,12 @@ from pykms_RequestV5 import kmsRequestV5 from pykms_RequestV6 import kmsRequestV6 from pykms_RpcBase import rpcBase from pykms_DB2Dict import kmsDB2Dict -from pykms_Misc import logger_create, check_logfile -from pykms_Misc import KmsParser, KmsException, KmsHelper -from pykms_Format import justify, byterize, enco, deco, ShellMessage, pretty_printer +from pykms_Misc import check_setup +from pykms_Misc import KmsParser, KmsParserException, KmsParserHelp +from pykms_Misc import kms_parser_get, kms_parser_check_optionals, kms_parser_check_positionals +from pykms_Format import justify, byterize, enco, deco, pretty_printer -clt_version = "py-kms_2020-02-02" +clt_version = "py-kms_2020-07-01" __license__ = "The Unlicense" __author__ = u"Matteo ℱan " __url__ = "https://github.com/SystemRage/py-kms" @@ -55,8 +57,10 @@ clt_options = { 'choi' : ["WindowsVista","Windows7","Windows8","Windows8.1","Windows10","Office2010","Office2013","Office2016","Office2019"]}, 'cmid' : {'help' : 'Use this flag to manually specify a CMID to use. If no CMID is specified, a random CMID will be generated.', 'def' : None, 'des' : "cmid"}, - 'name' : {'help' : 'Use this flag to manually specify an ASCII machineName to use. If no machineName is specified a random machineName \ -will be generated.', 'def' : None, 'des' : "machineName"}, + 'name' : {'help' : 'Use this flag to manually specify an ASCII machine name to use. If no machine name is specified a random one \ +will be generated.', 'def' : None, 'des' : "machine"}, + 'asyncmsg' : {'help' : 'Prints pretty / logging messages asynchronously. Desactivated by default.', + 'def' : False, 'des' : "asyncmsg"}, 'llevel' : {'help' : 'Use this option to set a log level. The default is \"ERROR\".', 'def' : "ERROR", 'des' : "loglevel", 'choi' : ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "MINI"]}, 'lfile' : {'help' : 'Use this option to set an output log file. The default is \"pykms_logclient.log\". Type \"STDOUT\" to view \ @@ -66,10 +70,7 @@ log info on stdout. Type \"FILESTDOUT\" to combine previous actions.', } def client_options(): - try: - client_parser = KmsParser(description = clt_description, epilog = 'version: ' + clt_version, add_help = False, allow_abbrew = False) - except TypeError: - client_parser = KmsParser(description = clt_description, epilog = 'version: ' + clt_version, add_help = False) + client_parser = KmsParser(description = clt_description, epilog = 'version: ' + clt_version, add_help = False) client_parser.add_argument("ip", nargs = "?", action = "store", default = clt_options['ip']['def'], help = clt_options['ip']['help'], type = str) client_parser.add_argument("port", nargs = "?", action = "store", default = clt_options['port']['def'], @@ -80,6 +81,8 @@ def client_options(): help = clt_options['cmid']['help'], type = str) client_parser.add_argument("-n", "--name", dest = clt_options['name']['des'] , default = clt_options['name']['def'], help = clt_options['name']['help'], type = str) + client_parser.add_argument("-y", "--async-msg", action = "store_true", dest = clt_options['asyncmsg']['des'], + default = clt_options['asyncmsg']['def'], help = clt_options['asyncmsg']['help']) client_parser.add_argument("-V", "--loglevel", dest = clt_options['llevel']['des'], action = "store", choices = clt_options['llevel']['choi'], default = clt_options['llevel']['def'], help = clt_options['llevel']['help'], type = str) @@ -87,24 +90,29 @@ def client_options(): default = clt_options['lfile']['def'], help = clt_options['lfile']['help'], type = str) client_parser.add_argument("-S", "--logsize", dest = clt_options['lsize']['des'], action = "store", default = clt_options['lsize']['def'], help = clt_options['lsize']['help'], type = float) + client_parser.add_argument("-h", "--help", action = "help", help = "show this help message and exit") try: - if "-h" in sys.argv[1:]: - KmsHelper().printer(parsers = [client_parser]) - clt_config.update(vars(client_parser.parse_args())) - except KmsException as e: - pretty_printer(put_text = "{reverse}{red}{bold}%s. Exiting...{end}" %str(e), to_exit = True) + userarg = sys.argv[1:] + + # Run help. + if any(arg in ["-h", "--help"] for arg in userarg): + KmsParserHelp().printer(parsers = [client_parser]) + + # Get stored arguments. + pykmsclt_zeroarg, pykmsclt_onearg = kms_parser_get(client_parser) + # Update pykms options for dict client config. + kms_parser_check_optionals(userarg, pykmsclt_zeroarg, pykmsclt_onearg, msg = 'optional py-kms client', + exclude_opt_len = ['-F', '--logfile']) + kms_parser_check_positionals(clt_config, client_parser.parse_args, msg = 'positional py-kms client') + + except KmsParserException as e: + pretty_printer(put_text = "{reverse}{red}{bold}%s. Exiting...{end}" %str(e), to_exit = True, where = "clt") def client_check(): - # Check logfile. - clt_config['logfile'] = check_logfile(clt_config['logfile'], clt_options['lfile']['def'], where = "clt") - - # Setup hidden or not messages. - ShellMessage.view = ( False if any(i in ['STDOUT', 'FILESTDOUT'] for i in clt_config['logfile']) else True ) - - # Create log. - logger_create(loggerclt, clt_config, mode = 'a') + # Setup and some checks. + check_setup(clt_config, clt_options, loggerclt, where = "clt") # Check cmid. if clt_config['cmid'] is not None: @@ -112,12 +120,22 @@ def client_check(): uuid.UUID(clt_config['cmid']) except ValueError: pretty_printer(log_obj = loggerclt.error, to_exit = True, where = "clt", - put_text = "{reverse}{red}{bold}Bad CMID. Exiting...{end}") - # Check machineName. - if clt_config['machineName'] is not None: - if len(clt_config['machineName']) < 2 or len(clt_config['machineName']) > 63: + put_text = "{reverse}{red}{bold}argument `-c/--cmid`: invalid with: '%s'. Exiting...{end}" %clt_config['cmid']) + + # Check machine name. + if clt_config['machine'] is not None: + try: + clt_config['machine'].encode('utf-16le') + + if len(clt_config['machine']) < 2: + pretty_printer(log_obj = loggerclt.error, to_exit = True, where = "clt", + put_text = "{reverse}{red}{bold}argument `-n/--name`: too short (required 2 - 63 chars). Exiting...{end}") + elif len(clt_config['machine']) > 63: + pretty_printer(log_obj = loggerclt.error, to_exit = True, where = "clt", + put_text = "{reverse}{red}{bold}argument `-n/--name`: too long (required 2 - 63 chars). Exiting...{end}") + except UnicodeEncodeError: pretty_printer(log_obj = loggerclt.error, to_exit = True, where = "clt", - put_text = "{reverse}{red}{bold}machineName must be between 2 and 63 characters in length. Exiting...{end}") + put_text = "{reverse}{red}{bold}argument `-n/--name`: invalid with: '%s'. Exiting...{end}" %clt_config['machine']) clt_config['call_id'] = 1 @@ -148,8 +166,14 @@ def client_update(): def client_create(): loggerclt.info("Connecting to %s on port %d..." % (clt_config['ip'], clt_config['port'])) - s = socket.create_connection((clt_config['ip'], clt_config['port'])) - loggerclt.info("Connection successful !") + try: + s = socket.create_connection((clt_config['ip'], clt_config['port'])) + loggerclt.info("Connection successful !") + except (socket.gaierror, socket.error) as e: + pretty_printer(log_obj = loggerclt.error, to_exit = True, where = "clt", + put_text = "{reverse}{red}{bold}Connection failed '%s:%d': %s. Exiting...{end}" %(clt_config['ip'], + clt_config['port'], + str(e))) binder = pykms_RpcBind.handler(None, clt_config) RPC_Bind = enco(str(binder.generateRequest()), 'latin-1') @@ -247,7 +271,7 @@ def createKmsRequestBase(): requestDict['previousClientMachineId'] = '\0' * 16 # I'm pretty sure this is supposed to be a null UUID. requestDict['requiredClientCount'] = clt_config['RequiredClientCount'] requestDict['requestTime'] = dt_to_filetime(datetime.datetime.utcnow()) - requestDict['machineName'] = (clt_config['machineName'] if (clt_config['machineName'] is not None) else + requestDict['machineName'] = (clt_config['machine'] if (clt_config['machine'] is not None) else ''.join(random.choice(string.ascii_letters + string.digits) for i in range(random.randint(2,63)))).encode('utf-16le') requestDict['mnPad'] = '\0'.encode('utf-16le') * (63 - len(requestDict['machineName'].decode('utf-16le'))) diff --git a/py-kms/pykms_Format.py b/py-kms/pykms_Format.py index 080609b..20fa8c4 100644 --- a/py-kms/pykms_Format.py +++ b/py-kms/pykms_Format.py @@ -5,6 +5,7 @@ import re import sys import os from collections import OrderedDict +import logging try: # Python 2.x imports @@ -16,6 +17,7 @@ except ImportError: import queue as Queue pyver = sys.version_info[:2] + #---------------------------------------------------------------------------------------------------------------------------------------------------------- def enco(strg, typ = 'latin-1'): @@ -195,13 +197,15 @@ if pyver < (3, 3): file = kwargs.get('file', sys.stdout) file.flush() if file is not None else sys.stdout.flush() -# based on: https://ryanjoneil.github.io/posts/2014-02-14-capturing-stdout-in-a-python-child-process.html, -# but not using threading/multiprocessing so: -# 1) message visualization order preserved. -# 2) newlines_count function output not wrong. +# based on: https://ryanjoneil.github.io/posts/2014-02-14-capturing-stdout-in-a-python-child-process.html +queue_print = Queue.Queue() + class ShellMessage(object): - view = True - count, remain, numlist = (0, 0, []) + viewsrv, viewclt = (True for _ in range(2)) + asyncmsgsrv, asyncmsgclt = (False for _ in range(2)) + indx, count, remain, numlist = (0, 0, 0, []) + loggersrv_pty = logging.getLogger('logsrvpty') + loggerclt_pty = logging.getLogger('logcltpty') class Collect(StringIO): # Capture string sent to stdout. @@ -215,8 +219,9 @@ class ShellMessage(object): self.put_text = put_text self.where = where self.plaintext = [] - self.path = os.path.dirname(os.path.abspath( __file__ )) + '/pykms_newlines.txt' - self.print_queue = Queue.Queue() + self.path_nl = os.path.dirname(os.path.abspath( __file__ )) + '/pykms_newlines.txt' + self.path_clean_nl = os.path.dirname(os.path.abspath( __file__ )) + '/pykms_clean_newlines.txt' + self.queue_get = Queue.Queue() def formatter(self, msgtofrmt): if self.newlines: @@ -236,14 +241,14 @@ class ShellMessage(object): def newlines_file(self, mode, *args): try: - with open(self.path, mode) as file: + with open(self.path_nl, mode) as file: if mode in ['w', 'a']: file.write(args[0]) elif mode == 'r': data = [int(i) for i in [line.rstrip('\n') for line in file.readlines()]] self.newlines, ShellMessage.remain = data[0], sum(data[1:]) except: - with open(self.path, 'w') as file: + with open(self.path_nl, 'w') as file: pass def newlines_count(self, num): @@ -265,40 +270,114 @@ class ShellMessage(object): self.continuecount = True elif num in [-2 ,-4]: self.newlines_file('r') - if num == 21: - ShellMessage.count, ShellMessage.remain, ShellMessage.numlist = (0, 0, []) - os.remove(self.path) - def run(self): - # view = False part. - if not ShellMessage.view: - if self.get_text: - self.newlines = 0 - if self.put_text is not None: - for msg in self.put_text: - self.formatter(msg) - else: - for num in self.nshell: - self.formatter(MsgMap[num]) - return self.plaintext + self.newlines_clean(num) + + def newlines_clean(self, num): + if num == 0: + with open(self.path_clean_nl, 'w') as file: + file.write('clean newlines') + try: + with open(self.path_clean_nl, 'r') as file: + some = file.read() + if num == 21: + ShellMessage.count, ShellMessage.remain, ShellMessage.numlist = (0, 0, []) + os.remove(self.path_nl) + os.remove(self.path_clean_nl) + except: + if num == 19: + ShellMessage.count, ShellMessage.remain, ShellMessage.numlist = (0, 0, []) + os.remove(self.path_nl) + + def putter(self, aqueue, toput): + try: + aqueue.put_nowait(toput) + except Queue.Full: + pass + + def execute(self): + self.manage() + ShellMessage.indx += 1 + + def print_logging_setup(self, logger, async_flag, formatter = logging.Formatter('%(name)s %(message)s')): + from pykms_GuiBase import gui_redirector + stream = gui_redirector(StringIO()) + handler = logging.StreamHandler(stream) + handler.name = 'LogStream' + handler.setLevel(logging.INFO) + handler.setFormatter(formatter) + + if logger.handlers: + logger.handlers = [] + + if async_flag: + from pykms_Misc import MultiProcessingLogHandler + logger.addHandler(MultiProcessingLogHandler('Thread-AsyncMsg{0}'.format(handler.name), handler = handler)) + else: + logger.addHandler(handler) + logger.setLevel(logging.INFO) + + def print_logging(self, toprint): + if (self.nshell and ((0 in self.nshell) or (2 in self.nshell and not ShellMessage.viewclt))) or ShellMessage.indx == 0: + from pykms_GuiBase import gui_redirector_setup, gui_redirector_clear + gui_redirector_setup() + gui_redirector_clear() + self.print_logging_setup(ShellMessage.loggersrv_pty, ShellMessage.asyncmsgsrv) + self.print_logging_setup(ShellMessage.loggerclt_pty, ShellMessage.asyncmsgclt) + + if self.where == 'srv': + ShellMessage.loggersrv_pty.info(toprint) + elif self.where == 'clt': + ShellMessage.loggerclt_pty.info(toprint) + + def notview(self): + if self.get_text: + self.newlines = 0 + if self.put_text is not None: + for msg in self.put_text: + self.formatter(msg) else: + for num in self.nshell: + self.formatter(MsgMap[num]) + self.putter(self.queue_get, self.plaintext) + + def manage(self): + if not ShellMessage.viewsrv: + # viewsrv = False, viewclt = True. + if ShellMessage.viewclt: + if self.where == 'srv': + self.notview() + return + else: + # viewsrv = False, viewclt = False. + self.notview() return + else: + # viewsrv = True, viewclt = False. + if not ShellMessage.viewclt: + if self.where == 'clt': + self.notview() + return + else: + # viewsrv = True, viewclt = True. + pass + # Do job. self.produce() - toprint = self.consume(timeout = 0.1) - # Redirect output. + toprint = self.consume(queue_print, timeout = 0.1) + if sys.stdout.isatty(): - print(toprint) + print(toprint, flush = True) else: try: - # Import after variables creation. - from pykms_GuiBase import gui_redirect - gui_redirect(toprint, self.where) + self.print_logging(toprint) except: - print(toprint) + print(toprint, flush = True) + # Get string/s printed. if self.get_text: - return self.plaintext + self.putter(self.queue_get, self.plaintext) + return def produce(self): # Save everything that would otherwise go to stdout. @@ -327,15 +406,12 @@ class ShellMessage(object): finally: # Restore stdout and send content. sys.stdout = sys.__stdout__ - try: - self.print_queue.put(outstream.getvalue()) - except Queue.Full: - pass + self.putter(queue_print, outstream.getvalue()) - def consume(self, timeout = None): + def consume(self, aqueue, timeout = None): try: - toprint = self.print_queue.get(block = timeout is not None, timeout = timeout) - self.print_queue.task_done() + toprint = aqueue.get(block = timeout is not None, timeout = timeout) + aqueue.task_done() return toprint except Queue.Empty: return None @@ -381,11 +457,13 @@ def pretty_printer(**kwargs): options['get_text'] = False # Process messages. - plain_messages = ShellMessage.Process(options['num_text'], - get_text = options['get_text'], - put_text = options['put_text'], - where = options['where']).run() + shmsg = ShellMessage.Process(options['num_text'], + get_text = options['get_text'], + put_text = options['put_text'], + where = options['where']) + shmsg.execute() + plain_messages = shmsg.consume(shmsg.queue_get, timeout = None) if options['log_obj']: for plain_message in plain_messages: options['log_obj'](plain_message) diff --git a/py-kms/pykms_GuiBase.py b/py-kms/pykms_GuiBase.py index 72df2cc..92673ab 100644 --- a/py-kms/pykms_GuiBase.py +++ b/py-kms/pykms_GuiBase.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- import os import sys @@ -21,12 +22,14 @@ except ImportError: import tkinter.font as tkFont from pykms_Server import srv_options, srv_version, srv_config, server_terminate, serverqueue, serverthread -from pykms_GuiMisc import ToolTip, TextDoubleScroll, TextRedirect, custom_background +from pykms_GuiMisc import ToolTip, TextDoubleScroll, TextRedirect, ListboxOfRadiobuttons +from pykms_GuiMisc import custom_background, custom_pages from pykms_Client import clt_options, clt_version, clt_config, client_thread -gui_version = "py-kms_gui_v2.0" -__license__ = "The Unlicense" +gui_version = "py-kms_gui_v3.0" +__license__ = "MIT License" __author__ = u"Matteo ℱan " +__copyright__ = "© Copyright 2020" __url__ = "https://github.com/SystemRage/py-kms" gui_description = "A GUI for py-kms." @@ -46,35 +49,48 @@ def get_ip_address(): else: ip = 'Unknown' return ip - -def gui_redirect(str_to_print, where): + +def gui_redirector(stream, redirect_to = TextRedirect.Pretty, redirect_conditio = True, stderr_side = "srv"): global txsrv, txclt, txcol + if redirect_conditio: + if stream == 'stdout': + sys.stdout = redirect_to(txsrv, txclt, txcol) + elif stream == 'stderr': + sys.stderr = redirect_to(txsrv, txclt, txcol, stderr_side) + else: + stream = redirect_to(txsrv, txclt, txcol) + return stream +def gui_redirector_setup(): + TextRedirect.Pretty.tag_num = 0 + TextRedirect.Pretty.newlinecut = [-1, -2, -4, -5] + +def gui_redirector_clear(): + global txsrv, oysrv try: - TextRedirect.StdoutRedirect(txsrv, txclt, txcol, str_to_print, where) + if oysrv: + txsrv.configure(state = 'normal') + txsrv.delete('1.0', 'end') + txsrv.configure(state = 'disabled') except: - print(str_to_print) + # self.onlysrv not defined (menu not used) + pass -##--------------------------------------------------------------------------------------------------------------------------------------------------------- +##----------------------------------------------------------------------------------------------------------------------------------------------------------- -class KmsGui(tk.Tk): - def browse(self, entrywidget, options): - path = filedialog.askdirectory() - if os.path.isdir(path): - entrywidget.delete('0', 'end') - entrywidget.insert('end', path + os.sep + os.path.basename(options['lfile']['def'])) - - +class KmsGui(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.wraplength = 200 serverthread.with_gui = True - self.validation_int = self.register(self.validate_int) + self.validation_int = (self.register(self.validate_int), "%S") + self.validation_float = (self.register(self.validate_float), "%P") ## Define fonts and colors. self.btnwinfont = tkFont.Font(family = 'Times', size = 12, weight = 'bold') self.othfont = tkFont.Font(family = 'Times', size = 9, weight = 'bold') self.optfont = tkFont.Font(family = 'Helvetica', size = 11, weight = 'bold') + self.optfontredux = tkFont.Font(family = 'Helvetica', size = 9, weight = 'bold') self.msgfont = tkFont.Font(family = 'Monospace', size = 6) # need a monospaced type (like courier, etc..). self.customcolors = { 'black' : '#000000', @@ -88,40 +104,191 @@ class KmsGui(tk.Tk): 'cyan' : '#AFEEEE', 'lavender': '#E6E6FA', } + + self.option_add('*TCombobox*Listbox.font', self.optfontredux) + self.gui_create() + + def browse(self, entrywidget, options): + path = filedialog.askdirectory() + if os.path.isdir(path): + entrywidget.delete('0', 'end') + entrywidget.insert('end', path + os.sep + os.path.basename(options['lfile']['def'])) + + def invert(self, widgets = []): + for widget in widgets: + if widget['state'] == 'normal': + widget.configure(state = 'disabled') + elif widget['state'] == 'disabled': + widget.configure(state = 'normal') + + def gui_menu(self): + self.onlysrv, self.onlyclt = (False for _ in range(2)) + menubar = tk.Menu(self) + prefmenu = tk.Menu(menubar, tearoff = 0, font = ("Noto Sans Regular", 10), borderwidth = 3, relief = 'ridge') + menubar.add_cascade(label = 'Preferences', menu = prefmenu) + prefmenu.add_command(label = 'Enable server-side mode', command = lambda: self.pref_onlysrv(prefmenu)) + prefmenu.add_command(label = 'Enable client-side mode', command = lambda: self.pref_onlyclt(prefmenu)) + self.config(menu = menubar) + def pref_onlysrv(self, menu): + global oysrv + + if self.onlyclt or serverthread.is_running_server: + return + self.onlysrv = not self.onlysrv + if self.onlysrv: + menu.entryconfigure(0, label = 'Disable server-side mode') + self.clt_on_show(force_remove = True) + else: + menu.entryconfigure(0, label = 'Enable server-side mode') + self.invert(widgets = [self.shbtnclt]) + oysrv = self.onlysrv + + def pref_onlyclt(self, menu): + if self.onlysrv or serverthread.is_running_server: + return + self.onlyclt = not self.onlyclt + if self.onlyclt: + menu.entryconfigure(1, label = 'Disable client-side mode') + if self.shbtnclt['text'] == 'SHOW\nCLIENT': + self.clt_on_show(force_view = True) + self.optsrvwin.grid_remove() + self.msgsrvwin.grid_remove() + gui_redirector('stderr', redirect_to = TextRedirect.Stderr, stderr_side = "clt") + else: + menu.entryconfigure(1, label = 'Enable client-side mode') + self.optsrvwin.grid() + self.msgsrvwin.grid() + gui_redirector('stderr', redirect_to = TextRedirect.Stderr) + + self.invert(widgets = [self.runbtnsrv, self.shbtnclt, self.runbtnclt]) + def gui_create(self): ## Create server gui self.gui_srv() ## Create client gui + other operations. self.gui_complete() + ## Create menu. + self.gui_menu() ## Create globals for printing process (redirect stdout). global txsrv, txclt, txcol txsrv = self.textboxsrv.get() txclt = self.textboxclt.get() txcol = self.customcolors ## Redirect stderr. - sys.stderr = TextRedirect.StderrRedirect(txsrv, txclt, txcol) - + gui_redirector('stderr', redirect_to = TextRedirect.Stderr) + + def gui_pages_show(self, pagename, side): + # https://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter + # https://www.reddit.com/r/learnpython/comments/7xxtsy/trying_to_understand_tkinter_and_how_to_switch/ + pageside = self.pagewidgets[side] + tk.Misc.lift(pageside["PageWin"][pagename], aboveThis = None) + keylist = list(pageside["PageWin"].keys()) + + for elem in [pageside["BtnAni"], pageside["LblAni"]]: + if pagename == "PageStart": + elem["Left"].config(state = "disabled") + if len(keylist) == 2: + elem["Right"].config(state = "normal") + elif pagename == "PageEnd": + elem["Right"].config(state = "disabled") + if len(keylist) == 2: + elem["Left"].config(state = "normal") + else: + for where in ["Left", "Right"]: + elem[where].config(state = "normal") + + if pagename != "PageStart": + page_l = keylist[keylist.index(pagename) - 1] + pageside["BtnAni"]["Left"]['command'] = lambda pag=page_l, pos=side: self.gui_pages_show(pag, pos) + if pagename != "PageEnd": + page_r = keylist[keylist.index(pagename) + 1] + pageside["BtnAni"]["Right"]['command'] = lambda pag=page_r, pos=side: self.gui_pages_show(pag, pos) + + def gui_pages_buttons(self, parent, side): + btnwin = tk.Canvas(parent, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') + btnwin.grid(row = 14, column = 2, padx = 2, pady = 2, sticky = 'nsew') + btnwin.grid_columnconfigure(1, weight = 1) + self.pagewidgets[side]["BtnWin"] = btnwin + + for position in ["Left", "Right"]: + if position == "Left": + col = [0, 0, 1] + stick = 'e' + elif position == "Right": + col = [2, 1, 0] + stick = 'w' + + aniwin = tk.Canvas(btnwin, background = self.customcolors['white'], borderwidth = 0, relief = 'ridge') + aniwin.grid(row = 0, column = col[0], padx = 5, pady = 5, sticky = 'nsew') + self.pagewidgets[side]["AniWin"][position] = aniwin + + lblani = tk.Label(aniwin, width = 1, height = 1) + lblani.grid(row = 0, column = col[1], padx = 2, pady = 2, sticky = stick) + self.pagewidgets[side]["LblAni"][position] = lblani + + btnani = tk.Button(aniwin) + btnani.grid(row = 0, column = col[2], padx = 2, pady = 2, sticky = stick) + self.pagewidgets[side]["BtnAni"][position] = btnani + ## Customize buttons. + custom_pages(self, side) + + def gui_pages_create(self, parent, side, create = {}): + self.pagewidgets.update({side : {"PageWin" : create, + "BtnWin" : None, + "BtnAni" : {"Left" : None, + "Right" : None}, + "AniWin" : {"Left" : None, + "Right" : None}, + "LblAni" : {"Left" : None, + "Right" : None}, + } + }) + + for pagename in self.pagewidgets[side]["PageWin"].keys(): + page = tk.Canvas(parent, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') + self.pagewidgets[side]["PageWin"][pagename] = page + page.grid(row = 0, column = 2, padx = 2, pady = 2, sticky = "nsew") + page.grid_columnconfigure(1, weight = 1) + self.gui_pages_buttons(parent = parent, side = side) + self.gui_pages_show("PageStart", side = side) + + def gui_store(self, side, typewidgets): + stored = [] + for pagename in self.pagewidgets[side]["PageWin"].keys(): + for widget in self.pagewidgets[side]["PageWin"][pagename].winfo_children(): + if widget.winfo_class() in typewidgets: + stored.append(widget) + return stored + def gui_srv(self): - ## Create main containers. ------------------------------------------------------------------------------------------------------------- + ## Create main containers. ------------------------------------------------------------------------------------------------------------------ self.masterwin = tk.Canvas(self, borderwidth = 3, relief = tk.RIDGE) self.btnsrvwin = tk.Canvas(self.masterwin, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') self.optsrvwin = tk.Canvas(self.masterwin, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') - # self.optaddsrvwin = tk.Canvas(self.masterwin, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') self.msgsrvwin = tk.Frame(self.masterwin, background = self.customcolors['black'], relief = 'ridge', width = 300, height = 200) - + ## Layout main containers. self.masterwin.grid(row = 0, column = 0, sticky = 'nsew') self.btnsrvwin.grid(row = 0, column = 1, padx = 2, pady = 2, sticky = 'nw') - self.optsrvwin.grid(row = 0, column = 2, padx = 2, pady = 2, sticky = 'nw') - # self.optaddsrvwin.grid(row = 0, column = 3, padx = 2, pady = 2, sticky = 'nw') + self.optsrvwin.grid(row = 0, column = 2, padx = 2, pady = 2, sticky = 'nsew') + self.optsrvwin.grid_rowconfigure(0, weight = 1) + self.optsrvwin.grid_columnconfigure(1, weight = 1) + + self.pagewidgets = {} + + ## Subpages of "optsrvwin". + self.gui_pages_create(parent = self.optsrvwin, side = "Srv", create = {"PageStart": None, + "PageEnd": None}) + + ## Continue to grid. self.msgsrvwin.grid(row = 1, column = 2, padx = 1, pady = 1, sticky = 'nsew') self.msgsrvwin.grid_propagate(False) self.msgsrvwin.grid_columnconfigure(0, weight = 1) self.msgsrvwin.grid_rowconfigure(0, weight = 1) - ## Create widgets (btnsrvwin) ----------------------------------------------------------------------------------------------------------- + ## Create widgets (btnsrvwin) --------------------------------------------------------------------------------------------------------------- self.statesrv = tk.Label(self.btnsrvwin, text = 'Server\nState:\nStopped', font = self.othfont, foreground = self.customcolors['red']) self.runbtnsrv = tk.Button(self.btnsrvwin, text = 'START\nSERVER', background = self.customcolors['green'], foreground = self.customcolors['white'], relief = 'flat', font = self.btnwinfont, command = self.srv_on_start) @@ -140,84 +307,96 @@ class KmsGui(tk.Tk): self.clearbtnsrv.grid(row = 3, column = 0, padx = 2, pady = 2, sticky = 'ew') self.exitbtnsrv.grid(row = 4, column = 0, padx = 2, pady = 2, sticky = 'ew') - ## Create widgets (optsrvwin) ------------------------------------------------------------------------------------------------------ + ## Create widgets (optsrvwin:Srv:PageWin:PageStart) ----------------------------------------------------------------------------------------- # Version. - ver = tk.Label(self.optsrvwin, text = 'You are running server version: ' + srv_version, foreground = self.customcolors['red'], + ver = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], + text = 'You are running server version: ' + srv_version, foreground = self.customcolors['red'], font = self.othfont) - self.allopts_srv = [] # Ip Address. - srvipaddlbl = tk.Label(self.optsrvwin, text = 'IP Address: ', font = self.optfont) - self.srvipadd = tk.Entry(self.optsrvwin, width = 10, font = self.optfont) + srvipaddlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'IP Address: ', font = self.optfont) + self.srvipadd = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.srvipadd.insert('end', srv_options['ip']['def']) ToolTip(self.srvipadd, text = srv_options['ip']['help'], wraplength = self.wraplength) - myipadd = tk.Label(self.optsrvwin, text = 'Your IP address is: {}'.format(get_ip_address()), foreground = self.customcolors['red'], - font = self.othfont) - self.allopts_srv.append(self.srvipadd) + myipadd = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Your IP address is: {}'.format(get_ip_address()), + foreground = self.customcolors['red'], font = self.othfont) # Port. - srvportlbl = tk.Label(self.optsrvwin, text = 'Port: ', font = self.optfont) - self.srvport = tk.Entry(self.optsrvwin, width = 10, font = self.optfont, validate = "key", validatecommand = (self.validation_int, "%S")) + srvportlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Port: ', font = self.optfont) + self.srvport = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_int) self.srvport.insert('end', str(srv_options['port']['def'])) ToolTip(self.srvport, text = srv_options['port']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.srvport) # EPID. - epidlbl = tk.Label(self.optsrvwin, text = 'EPID: ', font = self.optfont) - self.epid = tk.Entry(self.optsrvwin, width = 10, font = self.optfont) + epidlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'EPID: ', font = self.optfont) + self.epid = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.epid.insert('end', str(srv_options['epid']['def'])) ToolTip(self.epid, text = srv_options['epid']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.epid) # LCID. - lcidlbl = tk.Label(self.optsrvwin, text = 'LCID: ', font = self.optfont) - self.lcid = tk.Entry(self.optsrvwin, width = 10, font = self.optfont, validate = "key", validatecommand = (self.validation_int, "%S")) + lcidlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'LCID: ', font = self.optfont) + self.lcid = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_int) self.lcid.insert('end', str(srv_options['lcid']['def'])) ToolTip(self.lcid, text = srv_options['lcid']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.lcid) # HWID. - hwidlbl = tk.Label(self.optsrvwin, text = 'HWID: ', font = self.optfont) - self.hwid = tk.Entry(self.optsrvwin, width = 10, font = self.optfont) - self.hwid.insert('end', srv_options['hwid']['def']) + hwidlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'HWID: ', font = self.optfont) + self.hwid = ttk.Combobox(self.pagewidgets["Srv"]["PageWin"]["PageStart"], values = (str(srv_options['hwid']['def']), 'RANDOM'), + width = 17, height = 10, font = self.optfontredux) + self.hwid.set(str(srv_options['hwid']['def'])) ToolTip(self.hwid, text = srv_options['hwid']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.hwid) # Client Count - countlbl = tk.Label(self.optsrvwin, text = 'Client Count: ', font = self.optfont) - self.count = tk.Entry(self.optsrvwin, width = 10, font = self.optfont) + countlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Client Count: ', font = self.optfont) + self.count = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.count.insert('end', str(srv_options['count']['def'])) ToolTip(self.count, text = srv_options['count']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.count) # Activation Interval. - activlbl = tk.Label(self.optsrvwin, text = 'Activation Interval: ', font = self.optfont) - self.activ = tk.Entry(self.optsrvwin, width = 10, font = self.optfont, validate = "key", validatecommand = (self.validation_int, "%S")) + activlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Activation Interval: ', font = self.optfont) + self.activ = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_int) self.activ.insert('end', str(srv_options['activation']['def'])) ToolTip(self.activ, text = srv_options['activation']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.activ) # Renewal Interval. - renewlbl = tk.Label(self.optsrvwin, text = 'Activation Interval: ', font = self.optfont) - self.renew = tk.Entry(self.optsrvwin, width = 10, font = self.optfont, validate = "key", validatecommand = (self.validation_int, "%S")) + renewlbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Renewal Interval: ', font = self.optfont) + self.renew = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_int) self.renew.insert('end', str(srv_options['renewal']['def'])) ToolTip(self.renew, text = srv_options['renewal']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.renew) # Logfile. - srvfilelbl = tk.Label(self.optsrvwin, text = 'Logfile Path / Name: ', font = self.optfont) - self.srvfile = tk.Entry(self.optsrvwin, width = 10, font = self.optfont) + srvfilelbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Logfile Path / Name: ', font = self.optfont) + self.srvfile = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.srvfile.insert('end', srv_options['lfile']['def']) self.srvfile.xview_moveto(1) ToolTip(self.srvfile, text = srv_options['lfile']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.srvfile) - filebtnwin = tk.Button(self.optsrvwin, text = 'Browse', command = lambda: self.browse(self.srvfile, srv_options)) - self.allopts_srv.append(filebtnwin) + srvfilebtnwin = tk.Button(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Browse', + command = lambda: self.browse(self.srvfile, srv_options)) # Loglevel. - srvlevellbl = tk.Label(self.optsrvwin, text = 'Loglevel: ', font = self.optfont) - self.srvlevel = ttk.Combobox(self.optsrvwin, values = tuple(srv_options['llevel']['choi']), width = 10) + srvlevellbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Loglevel: ', font = self.optfont) + self.srvlevel = ttk.Combobox(self.pagewidgets["Srv"]["PageWin"]["PageStart"], values = tuple(srv_options['llevel']['choi']), + width = 10, height = 10, font = self.optfontredux, state = "readonly") self.srvlevel.set(srv_options['llevel']['def']) ToolTip(self.srvlevel, text = srv_options['llevel']['help'], wraplength = self.wraplength) - self.allopts_srv.append(self.srvlevel) - # Sqlite database. - self.chkval = tk.BooleanVar() - self.chkval.set(srv_options['sql']['def']) - chksql = tk.Checkbutton(self.optsrvwin, text = 'Create Sqlite\nDatabase', font = self.optfont, var = self.chkval) - ToolTip(chksql, text = srv_options['sql']['help'], wraplength = self.wraplength) - self.allopts_srv.append(chksql) + # Logsize. + srvsizelbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Logsize: ', font = self.optfont) + self.srvsize = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_float) + self.srvsize.insert('end', srv_options['lsize']['def']) + ToolTip(self.srvsize, text = srv_options['lsize']['help'], wraplength = self.wraplength) + # Asynchronous messages. + self.chkvalsrvasy = tk.BooleanVar() + self.chkvalsrvasy.set(srv_options['asyncmsg']['def']) + chksrvasy = tk.Checkbutton(self.pagewidgets["Srv"]["PageWin"]["PageStart"], text = 'Async\nMsg', + font = self.optfontredux, var = self.chkvalsrvasy, relief = 'groove') + ToolTip(chksrvasy, text = srv_options['asyncmsg']['help'], wraplength = self.wraplength) - ## Layout widgets (optsrvwin) + # Listbox radiobuttons server. + self.chksrvfile = ListboxOfRadiobuttons(self.pagewidgets["Srv"]["PageWin"]["PageStart"], + ['FILE', 'FILEOFF', 'STDOUT', 'STDOUTOFF', 'FILESTDOUT'], + self.optfontredux, + changed = [(self.srvfile, srv_options['lfile']['def']), + (srvfilebtnwin, ''), + (self.srvsize, srv_options['lsize']['def']), + (self.srvlevel, srv_options['llevel']['def'])], + width = 10, height = 1, borderwidth = 2, relief = 'ridge') + + ## Layout widgets (optsrvwin:Srv:PageWin:PageStart) ver.grid(row = 0, column = 0, columnspan = 3, padx = 5, pady = 5, sticky = 'ew') srvipaddlbl.grid(row = 1, column = 0, padx = 5, pady = 5, sticky = 'e') self.srvipadd.grid(row = 1, column = 1, padx = 5, pady = 5, sticky = 'ew') @@ -238,44 +417,90 @@ class KmsGui(tk.Tk): self.renew.grid(row = 9, column = 1, padx = 5, pady = 5, sticky = 'ew') srvfilelbl.grid(row = 10, column = 0, padx = 5, pady = 5, sticky = 'e') self.srvfile.grid(row = 10, column = 1, padx = 5, pady = 5, sticky = 'ew') - filebtnwin.grid(row = 10, column = 2, padx = 5, pady = 5, sticky = 'ew') - srvlevellbl.grid(row = 11, column = 0, padx = 5, pady = 5, sticky = 'e') - self.srvlevel.grid(row = 11, column = 1, padx = 5, pady = 5, sticky = 'ew') - chksql.grid(row = 12, column = 1, padx = 5, pady = 5, sticky = 'ew') + srvfilebtnwin.grid(row = 10, column = 2, padx = 5, pady = 5, sticky = 'ew') + self.chksrvfile.grid(row = 11, column = 1, padx = 5, pady = 5, sticky = 'ew') + chksrvasy.grid(row = 11, column = 2, padx = 5, pady = 5, sticky = 'ew') + srvlevellbl.grid(row = 12, column = 0, padx = 5, pady = 5, sticky = 'e') + self.srvlevel.grid(row = 12, column = 1, padx = 5, pady = 5, sticky = 'ew') + srvsizelbl.grid(row = 13, column = 0, padx = 5, pady = 5, sticky = 'e') + self.srvsize.grid(row = 13, column = 1, padx = 5, pady = 5, sticky = 'ew') - ## Create widgets and layout (msgsrvwin) ----------------------------------------------------------------------------------------------- + ## Create widgets (optsrvwin:Srv:PageWin:PageEnd)------------------------------------------------------------------------------------------- + # Timeout connection. + timeout0lbl = tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageEnd"], text = 'Timeout connection: ', font = self.optfont) + self.timeout0 = tk.Entry(self.pagewidgets["Srv"]["PageWin"]["PageEnd"], width = 16, font = self.optfont) + self.timeout0.insert('end', str(srv_options['time0']['def'])) + ToolTip(self.timeout0, text = srv_options['time0']['help'], wraplength = self.wraplength) + # Sqlite database. + self.chkvalsql = tk.BooleanVar() + self.chkvalsql.set(srv_options['sql']['def']) + chksql = tk.Checkbutton(self.pagewidgets["Srv"]["PageWin"]["PageEnd"], text = 'Create Sqlite\nDatabase', + font = self.optfontredux, var = self.chkvalsql, relief = 'groove') + ToolTip(chksql, text = srv_options['sql']['help'], wraplength = self.wraplength) + + ## Layout widgets (optsrvwin:Srv:PageWin:PageEnd) + # a label for vertical aligning with PageStart + tk.Label(self.pagewidgets["Srv"]["PageWin"]["PageEnd"], width = 0, + height = 0, bg = self.customcolors['lavender']).grid(row = 0, column = 0, padx = 5, pady = 5, sticky = 'nw') + timeout0lbl.grid(row = 1, column = 0, padx = 5, pady = 5, sticky = 'e') + self.timeout0.grid(row = 1, column = 1, padx = 5, pady = 5, sticky = 'w') + chksql.grid(row = 2, column = 1, padx = 5, pady = 5, sticky = 'w') + + # Store server-side widgets. + self.storewidgets_srv = self.gui_store(side = "Srv", typewidgets = ['Button', 'Entry', 'TCombobox', 'Checkbutton']) + self.storewidgets_srv.append(self.chksrvfile) + + ## Create widgets and layout (msgsrvwin) --------------------------------------------------------------------------------------------------- self.textboxsrv = TextDoubleScroll(self.msgsrvwin, background = self.customcolors['black'], wrap = 'none', state = 'disabled', relief = 'ridge', font = self.msgfont) self.textboxsrv.put() - - ## Create widgets (optaddsrvwin) ----------------------------------------------------------------------------------------------------- - # self.timeout = tk.Entry(self.optaddsrvwin, width = 10) - # self.timeout.insert('end', '555') - ## Layout widgets (optaddsrvwin) - # self.timeout.grid(row = 0, column = 0, padx = 5, pady = 5, sticky = 'e') - + + def always_centered(self, geo, centered, refs): + x = (self.winfo_screenwidth() // 2) - (self.winfo_width() // 2) + y = (self.winfo_screenheight() // 2) - (self.winfo_height() // 2) + w, h, dx, dy = geo.split('+')[0].split('x') + geo.split('+')[1:] + + if w == refs[1]: + if centered: + self.geometry('+%d+%d' %(x, y)) + centered = False + elif w == refs[0]: + if not centered: + self.geometry('+%d+%d' %(x, y)) + centered = True + + if dx != str(x) or dy != str(y): + self.geometry('+%d+%d' %(x, 0)) + + self.after(200, self.always_centered, self.geometry(), centered, refs) + def gui_complete(self): ## Create client widgets (optcltwin, msgcltwin, btncltwin) self.update_idletasks() # update Gui to get btnsrvwin values --> btncltwin. + minw, minh = self.winfo_width(), self.winfo_height() self.iconify() self.gui_clt() - minw, minh = self.winfo_width(), self.winfo_height() - # Main window custom background. + maxw, minh = self.winfo_width(), self.winfo_height() + ## Main window custom background. self.update_idletasks() # update Gui for custom background self.iconify() custom_background(self) - # Main window other modifications. + ## Main window other modifications. + self.eval('tk::PlaceWindow %s center' %self.winfo_pathname(self.winfo_id())) self.wm_attributes("-topmost", True) - self.protocol("WM_DELETE_WINDOW", lambda:0) - self.minsize(minw, minh) - self.resizable(True, False) - - def get_position(self, genericwidget): - x, y = (genericwidget.winfo_x(), genericwidget.winfo_y()) - w, h = (genericwidget.winfo_width(), genericwidget.winfo_height()) + self.protocol("WM_DELETE_WINDOW", lambda: 0) + ## Disable maximize button. + self.resizable(False, False) + ## Centered window. + self.always_centered(self.geometry(), False, [minw, maxw]) + + def get_position(self, widget): + x, y = (widget.winfo_x(), widget.winfo_y()) + w, h = (widget.winfo_width(), widget.winfo_height()) return x, y, w, h - def gui_clt(self): + def gui_clt(self): + self.count_clear = 0 self.optcltwin = tk.Canvas(self.masterwin, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') self.msgcltwin = tk.Frame(self.masterwin, background = self.customcolors['black'], relief = 'ridge', width = 300, height = 200) self.btncltwin = tk.Canvas(self.masterwin, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge') @@ -284,76 +509,98 @@ class KmsGui(tk.Tk): self.btncltwin_X = xb + 2 self.btncltwin_Y = yb + hb + 10 self.btncltwin.place(x = self.btncltwin_X, y = self.btncltwin_Y, bordermode = 'inside', anchor = 'nw') - self.optcltwin.grid(row = 0, column = 4, padx = 2, pady = 2, sticky = 'nw') + self.optcltwin.grid(row = 0, column = 4, padx = 2, pady = 2, sticky = 'nsew') + self.optcltwin.grid_rowconfigure(0, weight = 1) + self.optcltwin.grid_columnconfigure(1, weight = 1) + + ## Subpages of "optcltwin". + self.gui_pages_create(parent = self.optcltwin, side = "Clt", create = {"PageStart": None, + "PageEnd": None}) + + ## Continue to grid. self.msgcltwin.grid(row = 1, column = 4, padx = 1, pady = 1, sticky = 'nsew') self.msgcltwin.grid_propagate(False) self.msgcltwin.grid_columnconfigure(0, weight = 1) self.msgcltwin.grid_rowconfigure(0, weight = 1) - # Create widgets (btncltwin) ------------------------------------------------------------------------------------------------------------ + ## Create widgets (btncltwin) ---------------------------------------------------------------------------------------------------------------- self.runbtnclt = tk.Button(self.btncltwin, text = 'START\nCLIENT', background = self.customcolors['blue'], foreground = self.customcolors['white'], relief = 'flat', font = self.btnwinfont, state = 'disabled', command = self.clt_on_start) - - #self.othbutt = tk.Button(self.btncltwin, text = 'Botton\n2', background = self.customcolors['green'], - # foreground = self.customcolors['white'], relief = 'flat', font = self.btnwinfont) - - # Layout widgets (btncltwin) + + ## Layout widgets (btncltwin) self.runbtnclt.grid(row = 0, column = 0, padx = 2, pady = 2, sticky = 'ew') - #self.othbutt.grid(row = 1, column = 0, padx = 2, pady = 2, sticky = 'ew') - # Create widgets (optcltwin) ------------------------------------------------------------------------------------------------------------ + ## Create widgets (optcltwin:Clt:PageWin:PageStart) ------------------------------------------------------------------------------------------ # Version. - cltver = tk.Label(self.optcltwin, text = 'You are running client version: ' + clt_version, foreground = self.customcolors['red'], - font = self.othfont) - self.allopts_clt = [] + cltver = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'You are running client version: ' + clt_version, + foreground = self.customcolors['red'], font = self.othfont) # Ip Address. - cltipaddlbl = tk.Label(self.optcltwin, text = 'IP Address: ', font = self.optfont) - self.cltipadd = tk.Entry(self.optcltwin, width = 10, font = self.optfont) + cltipaddlbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'IP Address: ', font = self.optfont) + self.cltipadd = tk.Entry(self.pagewidgets["Clt"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.cltipadd.insert('end', clt_options['ip']['def']) ToolTip(self.cltipadd, text = clt_options['ip']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltipadd) # Port. - cltportlbl = tk.Label(self.optcltwin, text = 'Port: ', font = self.optfont) - self.cltport = tk.Entry(self.optcltwin, width = 10, font = self.optfont, validate = "key", validatecommand = (self.validation_int, "%S")) + cltportlbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Port: ', font = self.optfont) + self.cltport = tk.Entry(self.pagewidgets["Clt"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_int) self.cltport.insert('end', str(clt_options['port']['def'])) ToolTip(self.cltport, text = clt_options['port']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltport) # Mode. - cltmodelbl = tk.Label(self.optcltwin, text = 'Mode: ', font = self.optfont) - self.cltmode = ttk.Combobox(self.optcltwin, values = tuple(clt_options['mode']['choi']), width = 10) + cltmodelbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Mode: ', font = self.optfont) + self.cltmode = ttk.Combobox(self.pagewidgets["Clt"]["PageWin"]["PageStart"], values = tuple(clt_options['mode']['choi']), + width = 17, height = 10, font = self.optfontredux, state = "readonly") self.cltmode.set(clt_options['mode']['def']) ToolTip(self.cltmode, text = clt_options['mode']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltmode) # CMID. - cltcmidlbl = tk.Label(self.optcltwin, text = 'CMID: ', font = self.optfont) - self.cltcmid = tk.Entry(self.optcltwin, width = 10, font = self.optfont) + cltcmidlbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'CMID: ', font = self.optfont) + self.cltcmid = tk.Entry(self.pagewidgets["Clt"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.cltcmid.insert('end', str(clt_options['cmid']['def'])) ToolTip(self.cltcmid, text = clt_options['cmid']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltcmid) # Machine Name. - cltnamelbl = tk.Label(self.optcltwin, text = 'Machine Name: ', font = self.optfont) - self.cltname = tk.Entry(self.optcltwin, width = 10, font = self.optfont) + cltnamelbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Machine Name: ', font = self.optfont) + self.cltname = tk.Entry(self.pagewidgets["Clt"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.cltname.insert('end', str(clt_options['name']['def'])) ToolTip(self.cltname, text = clt_options['name']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltname) # Logfile. - cltfilelbl = tk.Label(self.optcltwin, text = 'Logfile Path / Name: ', font = self.optfont) - self.cltfile = tk.Entry(self.optcltwin, width = 10, font = self.optfont) + cltfilelbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Logfile Path / Name: ', font = self.optfont) + self.cltfile = tk.Entry(self.pagewidgets["Clt"]["PageWin"]["PageStart"], width = 10, font = self.optfont) self.cltfile.insert('end', clt_options['lfile']['def']) self.cltfile.xview_moveto(1) ToolTip(self.cltfile, text = clt_options['lfile']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltfile) - cltfilebtnwin = tk.Button(self.optcltwin, text = 'Browse', command = lambda: self.browse(self.cltfile, clt_options)) - self.allopts_clt.append(cltfilebtnwin) + cltfilebtnwin = tk.Button(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Browse', + command = lambda: self.browse(self.cltfile, clt_options)) # Loglevel. - cltlevellbl = tk.Label(self.optcltwin, text = 'Loglevel: ', font = self.optfont) - self.cltlevel = ttk.Combobox(self.optcltwin, values = tuple(clt_options['llevel']['choi']), width = 10) + cltlevellbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Loglevel: ', font = self.optfont) + self.cltlevel = ttk.Combobox(self.pagewidgets["Clt"]["PageWin"]["PageStart"], values = tuple(clt_options['llevel']['choi']), + width = 10, height = 10, font = self.optfontredux, state = "readonly") self.cltlevel.set(clt_options['llevel']['def']) ToolTip(self.cltlevel, text = clt_options['llevel']['help'], wraplength = self.wraplength) - self.allopts_clt.append(self.cltlevel) + + # Logsize. + cltsizelbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Logsize: ', font = self.optfont) + self.cltsize = tk.Entry(self.pagewidgets["Clt"]["PageWin"]["PageStart"], width = 10, font = self.optfont, validate = "key", + validatecommand = self.validation_float) + self.cltsize.insert('end', clt_options['lsize']['def']) + ToolTip(self.cltsize, text = clt_options['lsize']['help'], wraplength = self.wraplength) + # Asynchronous messages. + self.chkvalcltasy = tk.BooleanVar() + self.chkvalcltasy.set(clt_options['asyncmsg']['def']) + chkcltasy = tk.Checkbutton(self.pagewidgets["Clt"]["PageWin"]["PageStart"], text = 'Async\nMsg', + font = self.optfontredux, var = self.chkvalcltasy, relief = 'groove') + ToolTip(chkcltasy, text = clt_options['asyncmsg']['help'], wraplength = self.wraplength) + + # Listbox radiobuttons client. + self.chkcltfile = ListboxOfRadiobuttons(self.pagewidgets["Clt"]["PageWin"]["PageStart"], + ['FILE', 'FILEOFF', 'STDOUT', 'STDOUTOFF', 'FILESTDOUT'], + self.optfontredux, + changed = [(self.cltfile, clt_options['lfile']['def']), + (cltfilebtnwin, ''), + (self.cltsize, clt_options['lsize']['def']), + (self.cltlevel, clt_options['llevel']['def'])], + width = 10, height = 1, borderwidth = 2, relief = 'ridge') - # Layout widgets (optcltwin) + ## Layout widgets (optcltwin:Clt:PageWin:PageStart) cltver.grid(row = 0, column = 0, columnspan = 3, padx = 5, pady = 5, sticky = 'ew') cltipaddlbl.grid(row = 1, column = 0, padx = 5, pady = 5, sticky = 'e') self.cltipadd.grid(row = 1, column = 1, padx = 5, pady = 5, sticky = 'ew') @@ -365,47 +612,82 @@ class KmsGui(tk.Tk): self.cltcmid.grid(row = 4, column = 1, padx = 5, pady = 5, sticky = 'ew') cltnamelbl.grid(row = 5, column = 0, padx = 5, pady = 5, sticky = 'e') self.cltname.grid(row = 5, column = 1, padx = 5, pady = 5, sticky = 'ew') - cltfilelbl.grid(row = 6, column = 0, padx = 5, pady = 5, sticky = 'ew') - self.cltfile.grid(row = 6, column = 1, padx = 5, pady = 5, sticky = 'e') + cltfilelbl.grid(row = 6, column = 0, padx = 5, pady = 5, sticky = 'e') + self.cltfile.grid(row = 6, column = 1, padx = 5, pady = 5, sticky = 'ew') cltfilebtnwin.grid(row = 6, column = 2, padx = 5, pady = 5, sticky = 'ew') - cltlevellbl.grid(row = 7, column = 0, padx = 5, pady = 5, sticky = 'e') - self.cltlevel.grid(row = 7, column = 1, padx = 5, pady = 5, sticky = 'ew') + self.chkcltfile.grid(row = 7, column = 1, padx = 5, pady = 5, sticky = 'ew') + chkcltasy.grid(row = 7, column = 2, padx = 5, pady = 5, sticky = 'ew') + cltlevellbl.grid(row = 8, column = 0, padx = 5, pady = 5, sticky = 'e') + self.cltlevel.grid(row = 8, column = 1, padx = 5, pady = 5, sticky = 'ew') + cltsizelbl.grid(row = 9, column = 0, padx = 5, pady = 5, sticky = 'e') + self.cltsize.grid(row = 9, column = 1, padx = 5, pady = 5, sticky = 'ew') + + # ugly fix when client-side mode is activated. + templbl = tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageStart"], + bg = self.customcolors['lavender']).grid(row = 10, column = 0, + padx = 35, pady = 54, sticky = 'e') + + ## Create widgets (optcltwin:Clt:PageWin:PageEnd) ------------------------------------------------------------------------------------------- + + ## Layout widgets (optcltwin:Clt:PageWin:PageEnd) + # a label for vertical aligning with PageStart + tk.Label(self.pagewidgets["Clt"]["PageWin"]["PageEnd"], width = 0, + height = 0, bg = self.customcolors['lavender']).grid(row = 0, column = 0, padx = 5, pady = 5, sticky = 'nw') + + ## Store client-side widgets. + self.storewidgets_clt = self.gui_store(side = "Clt", typewidgets = ['Button', 'Entry', 'TCombobox', 'Checkbutton']) + self.storewidgets_clt.append(self.chkcltfile) - # Create widgets and layout (msgcltwin) ---------------------------------------------------------------------------------------------------------- + ## Create widgets and layout (msgcltwin) ----------------------------------------------------------------------------------------------------- self.textboxclt = TextDoubleScroll(self.msgcltwin, background = self.customcolors['black'], wrap = 'none', state = 'disabled', relief = 'ridge', font = self.msgfont) self.textboxclt.put() def prep_option(self, value): - value = None if value == 'None' else value try: + # is an INT return int(value) except (TypeError, ValueError): - # is NONE or is a STRING. - return value + try: + # is a FLOAT + return float(value) + except (TypeError, ValueError): + # is a STRING. + return value - def prep_logfile(self, optionlog): - if optionlog.startswith('FILESTDOUT '): - split = optionlog.split('FILESTDOUT ') - split[0] = 'FILESTDOUT' - return split - elif optionlog.startswith('STDOUT '): - split = optionlog.split('STDOUT ') - split[0] = 'STDOUT' - return split - else: - return optionlog + def prep_logfile(self, filepath, status): + # FILE (pretty on, log view off, logfile yes) + # FILEOFF (pretty on, log view off, no logfile) + # STDOUT (pretty off, log view on, no logfile) + # STDOUTOFF (pretty off, log view off, logfile yes) + # FILESTDOUT (pretty off, log view on, logfile yes) + + if status == 'FILE': + return filepath + elif status in ['FILESTDOUT', 'STDOUTOFF']: + return [status, filepath] + elif status in ['STDOUT', 'FILEOFF']: + return status def validate_int(self, value): - return value.isdigit() - - def clt_on_show(self, force = False): - if self.optcltwin.winfo_ismapped() or force: + return value == "" or value.isdigit() + + def validate_float(self, value): + if value == "": + return True + try: + float(value) + return True + except ValueError: + return False + + def clt_on_show(self, force_remove = False, force_view = False): + if self.optcltwin.winfo_ismapped() or force_remove: self.shbtnclt['text'] = 'SHOW\nCLIENT' self.optcltwin.grid_remove() self.msgcltwin.grid_remove() self.btncltwin.place_forget() - else: + elif not self.optcltwin.winfo_ismapped() or force_view: self.shbtnclt['text'] = 'HIDE\nCLIENT' self.optcltwin.grid() self.msgcltwin.grid() @@ -413,12 +695,12 @@ class KmsGui(tk.Tk): def srv_on_start(self): if self.runbtnsrv['text'] == 'START\nSERVER': + self.on_clear([txsrv, txclt]) self.srv_actions_start() # wait for switch. while not serverthread.is_running_server: pass - self.on_clear([txsrv, txclt]) self.srv_toggle_all(on_start = True) # run thread for interrupting server when an error happens. self.srv_eject_thread = threading.Thread(target = self.srv_eject, name = "Thread-SrvEjt") @@ -436,20 +718,24 @@ class KmsGui(tk.Tk): def srv_actions_start(self): srv_config[srv_options['ip']['des']] = self.srvipadd.get() srv_config[srv_options['port']['des']] = self.prep_option(self.srvport.get()) - srv_config[srv_options['epid']['des']] = self.prep_option(self.epid.get()) + srv_config[srv_options['epid']['des']] = self.epid.get() srv_config[srv_options['lcid']['des']] = self.prep_option(self.lcid.get()) srv_config[srv_options['hwid']['des']] = self.hwid.get() srv_config[srv_options['count']['des']] = self.prep_option(self.count.get()) srv_config[srv_options['activation']['des']] = self.prep_option(self.activ.get()) srv_config[srv_options['renewal']['des']] = self.prep_option(self.renew.get()) - srv_config[srv_options['lfile']['des']] = self.prep_logfile(self.srvfile.get()) + srv_config[srv_options['lfile']['des']] = self.prep_logfile(self.srvfile.get(), self.chksrvfile.state()) + srv_config[srv_options['asyncmsg']['des']] = self.chkvalsrvasy.get() srv_config[srv_options['llevel']['des']] = self.srvlevel.get() - srv_config[srv_options['sql']['des']] = self.chkval.get() + srv_config[srv_options['lsize']['des']] = self.prep_option(self.srvsize.get()) - ## TODO. - srv_config[srv_options['lsize']['des']] = 0 - srv_config[srv_options['time']['des']] = None + srv_config[srv_options['time0']['des']] = self.prep_option(self.timeout0.get()) + srv_config[srv_options['sql']['des']] = self.chkvalsql.get() + ## Redirect stdout. + gui_redirector('stdout', redirect_to = TextRedirect.Log, + redirect_conditio = (srv_config[srv_options['lfile']['des']] in ['STDOUT', 'FILESTDOUT'])) + gui_redirector_setup() serverqueue.put('start') def srv_actions_stop(self): @@ -468,14 +754,16 @@ class KmsGui(tk.Tk): if on_start: self.runbtnsrv.configure(text = 'STOP\nSERVER', background = self.customcolors['red'], foreground = self.customcolors['white']) - for widget in self.allopts_srv: + for widget in self.storewidgets_srv: widget.configure(state = 'disabled') self.runbtnclt.configure(state = 'normal') else: self.runbtnsrv.configure(text = 'START\nSERVER', background = self.customcolors['green'], foreground = self.customcolors['white']) - for widget in self.allopts_srv: + for widget in self.storewidgets_srv: widget.configure(state = 'normal') + if isinstance(widget, ListboxOfRadiobuttons): + widget.change() self.runbtnclt.configure(state = 'disabled') def srv_toggle_state(self): @@ -487,27 +775,36 @@ class KmsGui(tk.Tk): self.statesrv.configure(text = txt, foreground = color) def clt_on_start(self): + if self.onlyclt: + self.on_clear([txclt]) + else: + rng, add_newline = self.on_clear_setup() + self.on_clear([txsrv, txclt], clear_range = [rng, None], newline_list = [add_newline, False]) + self.clt_actions_start() # run thread for disabling interrupt server and client, when client running. self.clt_eject_thread = threading.Thread(target = self.clt_eject, name = "Thread-CltEjt") self.clt_eject_thread.setDaemon(True) self.clt_eject_thread.start() - self.on_clear([txsrv, txclt]) - for widget in self.allopts_clt + [self.runbtnsrv, self.runbtnclt]: + for widget in self.storewidgets_clt + [self.runbtnsrv, self.runbtnclt]: widget.configure(state = 'disabled') def clt_actions_start(self): clt_config[clt_options['ip']['des']] = self.cltipadd.get() clt_config[clt_options['port']['des']] = self.prep_option(self.cltport.get()) clt_config[clt_options['mode']['des']] = self.cltmode.get() - clt_config[clt_options['cmid']['des']] = self.prep_option(self.cltcmid.get()) - clt_config[clt_options['name']['des']] = self.prep_option(self.cltname.get()) + clt_config[clt_options['cmid']['des']] = self.cltcmid.get() + clt_config[clt_options['name']['des']] = self.cltname.get() + clt_config[clt_options['lfile']['des']] = self.prep_logfile(self.cltfile.get(), self.chkcltfile.state()) + clt_config[clt_options['asyncmsg']['des']] = self.chkvalcltasy.get() clt_config[clt_options['llevel']['des']] = self.cltlevel.get() - clt_config[clt_options['lfile']['des']] = self.prep_logfile(self.cltfile.get()) + clt_config[clt_options['lsize']['des']] = self.prep_option(self.cltsize.get()) - ## TODO. - clt_config[clt_options['lsize']['des']] = 0 + ## Redirect stdout. + gui_redirector('stdout', redirect_to = TextRedirect.Log, + redirect_conditio = (clt_config[clt_options['lfile']['des']] in ['STDOUT', 'FILESTDOUT'])) + gui_redirector_setup() # run client (in a thread). self.clientthread = client_thread(name = "Thread-Clt") @@ -518,8 +815,18 @@ class KmsGui(tk.Tk): def clt_eject(self): while self.clientthread.is_alive(): sleep(0.1) - for widget in self.allopts_clt + [self.runbtnsrv, self.runbtnclt]: - widget.configure(state = 'normal') + + widgets = self.storewidgets_clt + [self.runbtnclt] + if not self.onlyclt: + widgets += [self.runbtnsrv] + + for widget in widgets: + if isinstance(widget, ttk.Combobox): + widget.configure(state = 'readonly') + else: + widget.configure(state = 'normal') + if isinstance(widget, ListboxOfRadiobuttons): + widget.change() def on_exit(self): if serverthread.is_running_server: @@ -530,8 +837,38 @@ class KmsGui(tk.Tk): server_terminate(serverthread, exit_thread = True) self.destroy() - def on_clear(self, widgetlist): - for widget in widgetlist: + def on_clear_setup(self): + if any(opt in ['STDOUT', 'FILESTDOUT'] for opt in srv_config[srv_options['lfile']['des']]): + if self.count_clear == 0: + self.ini = txsrv.index('end') + add_newline = False + else: + if self.count_clear == 1: + self.ini = '%s.0' %(int(self.ini[0]) - 1) + else: + self.ini = '%s.0' %(int(self.ini[0])) + add_newline = True + rng = [self.ini, 'end'] + self.count_clear += 1 + else: + rng, add_newline = None, False + self.count_clear = 0 + + return rng, add_newline + + def on_clear(self, widget_list, clear_range = None, newline_list = []): + if newline_list == []: + newline_list = len(widget_list) * [False] + + for num, couple in enumerate(zip(widget_list, newline_list)): + widget, add_n = couple + try: + ini, fin = clear_range[num] + except TypeError: + ini, fin = '1.0', 'end' + widget.configure(state = 'normal') - widget.delete('1.0', 'end') + widget.delete(ini, fin) + if add_n: + widget.insert('end', '\n') widget.configure(state = 'disabled') diff --git a/py-kms/pykms_GuiMisc.py b/py-kms/pykms_GuiMisc.py index 74bcb64..fef341f 100644 --- a/py-kms/pykms_GuiMisc.py +++ b/py-kms/pykms_GuiMisc.py @@ -4,6 +4,8 @@ import os import re import sys from collections import Counter +from time import sleep +import threading try: # Python 2.x imports @@ -18,7 +20,7 @@ except ImportError: from pykms_Format import MsgMap, unshell_message, unformat_message -#--------------------------------------------------------------------------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------------------------------------------------------------------------ # https://stackoverflow.com/questions/3221956/how-do-i-display-tooltips-in-tkinter class ToolTip(object): @@ -117,39 +119,23 @@ class ToolTip(object): tw.destroy() self.tw = None -##-------------------------------------------------------------------------------------------------------------------------------------------------------- -# https://stackoverflow.com/questions/2914603/segmentation-fault-while-redirecting-sys-stdout-to-tkinter-text-widget -# https://stackoverflow.com/questions/7217715/threadsafe-printing-across-multiple-processes-python-2-x -# https://stackoverflow.com/questions/3029816/how-do-i-get-a-thread-safe-print-in-python-2-6 -# https://stackoverflow.com/questions/20303291/issue-with-redirecting-stdout-to-tkinter-text-widget-with-threads - -class TextRedirect(object): - class StdoutRedirect(object): - tag_num = 0 +##----------------------------------------------------------------------------------------------------------------------------------------------------------- +class TextRedirect(object): + class Pretty(object): grpmsg = unformat_message([MsgMap[1], MsgMap[7], MsgMap[12], MsgMap[20]]) arrows = [ item[0] for item in grpmsg ] clt_msg_nonewline = [ item[1] for item in grpmsg ] arrows = list(set(arrows)) lenarrow = len(arrows[0]) srv_msg_nonewline = [ item[0] for item in unformat_message([MsgMap[2], MsgMap[5], MsgMap[13], MsgMap[18]]) ] - terminator = unformat_message([MsgMap[21]])[0][0] - msg_align = [ msg[0].replace('\t', '').replace('\n', '') for msg in unformat_message([MsgMap[-2], MsgMap[-4]])] - newlinecut = [-1, -2, -4, -5] + msg_align = [ msg[0].replace('\t', '').replace('\n', '') for msg in unformat_message([MsgMap[-2], MsgMap[-4]]) ] - def __init__(self, srv_text_space, clt_text_space, customcolors, str_to_print, where): + def __init__(self, srv_text_space, clt_text_space, customcolors): self.srv_text_space = srv_text_space self.clt_text_space = clt_text_space self.customcolors = customcolors - self.str_to_print = str_to_print - self.where = where - self.textbox_do() - def textbox_finish(self, message): - if message == self.terminator: - TextRedirect.StdoutRedirect.tag_num = 0 - TextRedirect.StdoutRedirect.newlinecut = [-1, -2, -4, -5] - def textbox_write(self, tag, message, color, extras): widget = self.textbox_choose(message) self.w_maxpix, self.h_maxpix = widget.winfo_width(), widget.winfo_height() @@ -159,16 +145,17 @@ class TextRedirect(object): self.textbox_color(tag, widget, color, self.customcolors['black'], extras) widget.after(100, widget.see('end')) widget.configure(state = 'disabled') - self.textbox_finish(message) - + def textbox_choose(self, message): - if self.where == "srv": + if any(item.startswith('logsrv') for item in [message, self.str_to_print]): self.srv_text_space.focus_set() + self.where = "srv" return self.srv_text_space - elif self.where == "clt": + elif any(item.startswith('logclt') for item in [message, self.str_to_print]): self.clt_text_space.focus_set() + self.where = "clt" return self.clt_text_space - + def textbox_color(self, tag, widget, forecolor = 'white', backcolor = 'black', extras = []): for extra in extras: if extra == 'bold': @@ -209,8 +196,8 @@ class TextRedirect(object): # horizontal align. if msg_unformat in self.msg_align: msg_strip = message.lstrip('\n') - message = '\n' * (len(message) - len(msg_strip) + TextRedirect.StdoutRedirect.newlinecut[0]) + msg_strip - TextRedirect.StdoutRedirect.newlinecut.pop(0) + message = '\n' * (len(message) - len(msg_strip) + TextRedirect.Pretty.newlinecut[0]) + msg_strip + TextRedirect.Pretty.newlinecut.pop(0) count = Counter(message) countab = (count['\t'] if count['\t'] != 0 else 1) @@ -218,26 +205,50 @@ class TextRedirect(object): return message def textbox_do(self): - msgs, TextRedirect.StdoutRedirect.tag_num = unshell_message(self.str_to_print, TextRedirect.StdoutRedirect.tag_num) + msgs, TextRedirect.Pretty.tag_num = unshell_message(self.str_to_print, TextRedirect.Pretty.tag_num) for tag in msgs: self.textbox_write(tag, msgs[tag]['text'], self.customcolors[msgs[tag]['color']], msgs[tag]['extra']) - - class StderrRedirect(StdoutRedirect): - def __init__(self, srv_text_space, clt_text_space, customcolors): + + def flush(self): + pass + + def write(self, string): + if string != '\n': + self.str_to_print = string + self.textbox_do() + + class Stderr(Pretty): + def __init__(self, srv_text_space, clt_text_space, customcolors, side): self.srv_text_space = srv_text_space self.clt_text_space = clt_text_space self.customcolors = customcolors + self.side = side self.tag_err = 'STDERR' self.xfont = tkFont.Font(font = self.srv_text_space['font']) + + def textbox_choose(self, message): + if self.side == "srv": + return self.srv_text_space + elif self.side == "clt": + return self.clt_text_space def write(self, string): - self.textbox_color(self.tag_err, self.srv_text_space, self.customcolors['red'], self.customcolors['black']) + widget = self.textbox_choose(string) + self.textbox_color(self.tag_err, widget, self.customcolors['red'], self.customcolors['black']) self.srv_text_space.configure(state = 'normal') self.srv_text_space.insert('end', string, self.tag_err) self.srv_text_space.see('end') self.srv_text_space.configure(state = 'disabled') + + class Log(Pretty): + def textbox_format(self, message): + if message.startswith('logsrv'): + message = message.replace('logsrv ', '') + if message.startswith('logclt'): + message = message.replace('logclt ', '') + return message + '\n' -##------------------------------------------------------------------------------------------------------------------------------------------------------- +##----------------------------------------------------------------------------------------------------------------------------------------------------------- class TextDoubleScroll(tk.Frame): def __init__(self, master, **kwargs): """ Initialize. @@ -245,8 +256,8 @@ class TextDoubleScroll(tk.Frame): - vertical scrollbar - text widget """ - self.master = master tk.Frame.__init__(self, master) + self.master = master self.textbox = tk.Text(self.master, **kwargs) self.sizegrip = ttk.Sizegrip(self.master) @@ -278,43 +289,237 @@ class TextDoubleScroll(tk.Frame): """ Return the "frame" useful to place inner controls. """ return self.textbox -##-------------------------------------------------------------------------------------------------------------------------------------------------- +##----------------------------------------------------------------------------------------------------------------------------------------------------------- def custom_background(window): + # first level canvas. allwidgets = window.grid_slaves(0,0)[0].grid_slaves() + window.grid_slaves(0,0)[0].place_slaves() - widgets = [ widget for widget in allwidgets if widget.winfo_class() == 'Canvas'] + widgets_alphalow = [ widget for widget in allwidgets if widget.winfo_class() == 'Canvas'] + widgets_alphahigh = [] + # sub-level canvas. + for side in ["Srv", "Clt"]: + widgets_alphahigh.append(window.pagewidgets[side]["BtnWin"]) + for position in ["Left", "Right"]: + widgets_alphahigh.append(window.pagewidgets[side]["AniWin"][position]) + for pagename in window.pagewidgets[side]["PageWin"].keys(): + widgets_alphalow.append(window.pagewidgets[side]["PageWin"][pagename]) try: from PIL import Image, ImageTk # Open Image. - img = Image.open(os.path.dirname(os.path.abspath( __file__ )) + "/pykms_Keys.gif") + img = Image.open(os.path.dirname(os.path.abspath( __file__ )) + "/graphics/pykms_Keys.gif") + img = img.convert('RGBA') # Resize image. img.resize((window.winfo_width(), window.winfo_height()), Image.ANTIALIAS) # Put semi-transparent background chunks. - window.backcrops = [] - - for widget in widgets: - x, y, w, h = window.get_position(widget) - cropped = img.crop((x, y, x + w, y + h)) - cropped.putalpha(24) - window.backcrops.append(ImageTk.PhotoImage(cropped)) - - # Not in same loop to prevent reference garbage. - for crop, widget in zip(window.backcrops, widgets): - widget.create_image(1, 1, image = crop, anchor = 'nw') + window.backcrops_alphalow, window.backcrops_alphahigh = ([] for _ in range(2)) + + def cutter(master, image, widgets, crops, alpha): + for widget in widgets: + x, y, w, h = master.get_position(widget) + cropped = image.crop((x, y, x + w, y + h)) + cropped.putalpha(alpha) + crops.append(ImageTk.PhotoImage(cropped)) + # Not in same loop to prevent reference garbage. + for crop, widget in zip(crops, widgets): + widget.create_image(1, 1, image = crop, anchor = 'nw') + + cutter(window, img, widgets_alphalow, window.backcrops_alphalow, 36) + cutter(window, img, widgets_alphahigh, window.backcrops_alphahigh, 96) # Put semi-transparent background overall. - img.putalpha(96) + img.putalpha(128) window.backimg = ImageTk.PhotoImage(img) window.masterwin.create_image(1, 1, image = window.backimg, anchor = 'nw') except ImportError: - for widget in widgets: + for widget in widgets_alphalow + widgets_alphahigh: widget.configure(background = window.customcolors['lavender']) # Hide client. - window.clt_on_show(force = True) + window.clt_on_show(force_remove = True) # Show Gui. window.deiconify() + +##----------------------------------------------------------------------------------------------------------------------------------------------------------- +class Animation(object): + def __init__(self, gifpath, master, widget, loop = False): + from PIL import Image, ImageTk, ImageSequence + + self.master = master + self.widget = widget + self.loop = loop + self.cancelid = None + self.flagstop = False + self.index = 0 + self.frames = [] + + img = Image.open(gifpath) + size = img.size + for frame in ImageSequence.Iterator(img): + static_img = ImageTk.PhotoImage(frame.convert('RGBA')) + try: + static_img.delay = int(frame.info['duration']) + except KeyError: + static_img.delay = 100 + self.frames.append(static_img) + + self.widget.configure(width = size[0], height = size[1]) + self.initialize() + + def initialize(self): + self.widget.configure(image = self.frames[0]) + self.widget.image = self.frames[0] + + def deanimate(self): + while not self.flagstop: + pass + self.flagstop = False + self.index = 0 + self.widget.configure(relief = "raised") + + def animate(self): + frame = self.frames[self.index] + self.widget.configure(image = frame, relief = "sunken") + self.index += 1 + self.cancelid = self.master.after(frame.delay, self.animate) + if self.index == len(self.frames): + if self.loop: + self.index = 0 + else: + self.stop() + + def start(self, event = None): + if str(self.widget['state']) != 'disabled': + if self.cancelid is None: + if not self.loop: + self.btnani_thread = threading.Thread(target = self.deanimate, name = "Thread-BtnAni") + self.btnani_thread.setDaemon(True) + self.btnani_thread.start() + self.cancelid = self.master.after(self.frames[0].delay, self.animate) + + def stop(self, event = None): + if self.cancelid: + self.master.after_cancel(self.cancelid) + self.cancelid = None + self.flagstop = True + self.initialize() + + +def custom_pages(window, side): + buttons = window.pagewidgets[side]["BtnAni"] + labels = window.pagewidgets[side]["LblAni"] -##--------------------------------------------------------------------------------------------------------------------------------------------------------- + for position in buttons.keys(): + buttons[position].config(anchor = "center", + font = window.btnwinfont, + background = window.customcolors['white'], + activebackground = window.customcolors['white'], + borderwidth = 2) + + try: + anibtn = Animation(os.path.dirname(os.path.abspath( __file__ )) + "/graphics/pykms_Keyhole_%s.gif" %position, + window, buttons[position], loop = False) + anilbl = Animation(os.path.dirname(os.path.abspath( __file__ )) + "/graphics/pykms_Arrow_%s.gif" %position, + window, labels[position], loop = True) + + def animationwait(master, button, btn_animation, lbl_animation): + while btn_animation.cancelid: + pass + sleep(1) + x, y = master.winfo_pointerxy() + if master.winfo_containing(x, y) == button: + lbl_animation.start() + + def animationcombo(master, button, btn_animation, lbl_animation): + wait_thread = threading.Thread(target = animationwait, + args = (master, button, btn_animation, lbl_animation), + name = "Thread-WaitAni") + wait_thread.setDaemon(True) + wait_thread.start() + lbl_animation.stop() + btn_animation.start() + + buttons[position].bind("", lambda event, anim1 = anibtn, anim2 = anilbl, + bt = buttons[position], win = window: + animationcombo(win, bt, anim1, anim2)) + buttons[position].bind("", anilbl.start) + buttons[position].bind("", anilbl.stop) + + except ImportError: + buttons[position].config(activebackground = window.customcolors['blue'], + foreground = window.customcolors['blue']) + labels[position].config(background = window.customcolors['lavender']) + + if position == "Left": + buttons[position].config(text = '<<') + elif position == "Right": + buttons[position].config(text = '>>') + +##----------------------------------------------------------------------------------------------------------------------------------------------------------- +class ListboxOfRadiobuttons(tk.Frame): + def __init__(self, master, radios, font, changed, **kwargs): + tk.Frame.__init__(self, master) + + self.master = master + self.radios = radios + self.font = font + self.changed = changed + + self.scrollv = tk.Scrollbar(self, orient = "vertical") + self.textbox = tk.Text(self, yscrollcommand = self.scrollv.set, **kwargs) + self.scrollv.config(command = self.textbox.yview) + # layout. + self.scrollv.pack(side = "right", fill = "y") + self.textbox.pack(side = "left", fill = "both", expand = True) + # create radiobuttons. + self.radiovar = tk.StringVar() + self.radiovar.set('FILE') + self.create() + + def create(self): + self.rdbtns = [] + for n, nameradio in enumerate(self.radios): + rdbtn = tk.Radiobutton(self, text = nameradio, value = nameradio, variable = self.radiovar, + font = self.font, indicatoron = 0, width = 15, + borderwidth = 3, selectcolor = 'yellow', command = self.change) + self.textbox.window_create("end", window = rdbtn) + # to force one checkbox per line + if n != len(self.radios) - 1: + self.textbox.insert("end", "\n") + self.rdbtns.append(rdbtn) + self.textbox.configure(state = "disabled") + + def change(self): + st = self.state() + for widget, default in self.changed: + wclass = widget.winfo_class() + if st in ['STDOUT', 'FILEOFF']: + if wclass == 'Entry': + widget.delete(0, 'end') + widget.configure(state = "disabled") + elif wclass == 'TCombobox': + if st == 'STDOUT': + widget.set(default) + widget.configure(state = "readonly") + elif st == 'FILEOFF': + widget.set('') + widget.configure(state = "disabled") + elif st in ['FILE', 'FILESTDOUT', 'STDOUTOFF']: + if wclass == 'Entry': + widget.configure(state = "normal") + widget.delete(0, 'end') + widget.insert('end', default) + widget.xview_moveto(1) + elif wclass == 'TCombobox': + widget.configure(state = "readonly") + widget.set(default) + elif wclass == 'Button': + widget.configure(state = "normal") + + def configure(self, state): + for rb in self.rdbtns: + rb.configure(state = state) + + def state(self): + return self.radiovar.get() diff --git a/py-kms/pykms_Misc.py b/py-kms/pykms_Misc.py index 3db56a5..89bf84d 100644 --- a/py-kms/pykms_Misc.py +++ b/py-kms/pykms_Misc.py @@ -6,9 +6,9 @@ import logging import os import argparse from logging.handlers import RotatingFileHandler -from pykms_Format import ColorExtraMap, pretty_printer +from pykms_Format import ColorExtraMap, ShellMessage, pretty_printer -#----------------------------------------------------------------------------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------------------------------------------------------------------------ # https://stackoverflow.com/questions/2183233/how-to-add-a-custom-loglevel-to-pythons-logging-facility # https://stackoverflow.com/questions/17558552/how-do-i-add-custom-field-to-python-log-format-string @@ -86,23 +86,104 @@ class LevelFormatter(logging.Formatter): formatter = self.formatters.get(record.levelno, self.default_fmt) return formatter.format(record) +# based on https://github.com/jruere/multiprocessing-logging (license LGPL-3.0) +from multiprocessing import Queue as MPQueue +try: + # Python 2.x imports + import Queue as Queue +except ImportError: + # Python 3.x imports + import queue as Queue +import threading + +class MultiProcessingLogHandler(logging.Handler): + def __init__(self, name, handler = None): + super(MultiProcessingLogHandler, self).__init__() + self.queue = MPQueue(-1) + if handler is None: + handler = logging.StreamHandler() + self.handler = handler + self.name = handler.name + + self.setLevel(self.handler.level) + self.setFormatter(self.handler.formatter) + self.filters = self.handler.filters + + self.is_closed = False + self.receive_thread = threading.Thread(target = self.receive, name = name) + self.receive_thread.daemon = True + self.receive_thread.start() + + def setFormatter(self, fmt): + super(MultiProcessingLogHandler, self).setFormatter(fmt) + self.handler.setFormatter(fmt) + + def emit(self, record): + try: + if record.args: + record.msg = record.msg %record.args + record.args = None + if record.exc_info: + dummy = self.format(record) + record.exc_info = None + self.queue.put_nowait(record) + except (KeyboardInterrupt, SystemExit): + raise + except: + self.handleError(record) + + def receive(self): + while not (self.is_closed and self.queue.empty()): + try: + record = self.queue.get(timeout = 0.2) + self.handler.emit(record) + except (KeyboardInterrupt, SystemExit): + raise + except EOFError: + break + except Queue.Empty: + pass + except: + logging.exception('Error in log handler.') + self.queue.close() + self.queue.join_thread() + + def close(self): + if not self.is_closed: + self.is_closed = True + self.receive_thread.join(5.0) + self.handler.close() + super(MultiProcessingLogHandler, self).close() + def logger_create(log_obj, config, mode = 'a'): # Create new level. add_logging_level('MINI', logging.CRITICAL + 10) + log_handlers = [] # Configure visualization. - log_handlers = [] - if any(i in ['STDOUT', 'FILESTDOUT'] for i in config['logfile']): - # (Only STDOUT) or (logfile and STDOUT) - log_handlers.append(logging.StreamHandler(sys.stdout)) - if 'FILESTDOUT' in config['logfile']: - log_handlers.append(RotatingFileHandler(filename = config['logfile'][1], mode = mode, maxBytes = int(config['logsize'] * 1024 * 512), - backupCount = 1, encoding = None, delay = 0)) + if any(opt in ['STDOUT', 'FILESTDOUT', 'STDOUTOFF'] for opt in config['logfile']): + if any(opt in ['STDOUT', 'FILESTDOUT'] for opt in config['logfile']): + # STDOUT or FILESTDOUT. + hand_stdout = logging.StreamHandler(sys.stdout) + hand_stdout.name = 'LogStdout' + log_handlers.append(hand_stdout) + if any(opt in ['STDOUTOFF', 'FILESTDOUT'] for opt in config['logfile']): + # STDOUTOFF or FILESTDOUT. + hand_rotate = RotatingFileHandler(filename = config['logfile'][1], mode = mode, maxBytes = int(config['logsize'] * 1024 * 512), + backupCount = 1, encoding = None, delay = 0) + hand_rotate.name = 'LogRotate' + log_handlers.append(hand_rotate) + elif 'FILEOFF' in config['logfile']: + hand_null = logging.FileHandler(os.devnull) + hand_null.name = 'LogNull' + log_handlers.append(hand_null) else: - # Only logfile. - log_handlers.append(RotatingFileHandler(filename = config['logfile'][0], mode = mode, maxBytes = int(config['logsize'] * 1024 * 512), - backupCount = 1, encoding = None, delay = 0)) + # FILE. + hand_rotate = RotatingFileHandler(filename = config['logfile'][0], mode = mode, maxBytes = int(config['logsize'] * 1024 * 512), + backupCount = 1, encoding = None, delay = 0) + hand_rotate.name = 'LogRotate' + log_handlers.append(hand_rotate) # Configure formattation. try: @@ -110,43 +191,56 @@ def logger_create(log_obj, config, mode = 'a'): except AttributeError: levelnames = logging._levelNames levelnum = [k for k in levelnames if k != 0] - frmt0 = '%(asctime)s %(levelname)-8s %(message)s' - frmt1 = '[%(asctime)s] [%(levelname)-8s] %(host)s %(status)s %(product)s %(message)s' - levelformdict = {} - for num in levelnum: - if num != logging.CRITICAL + 10: - levelformdict[num] = frmt0 - else: - levelformdict[num] = frmt1 - # Set level and format. - levelformdictcopy = levelformdict.copy() + frmt_gen = '%(asctime)s %(levelname)-8s %(message)s' + frmt_std = '%(name)s %(asctime)s %(levelname)-8s %(message)s' + frmt_min = '[%(asctime)s] [%(levelname)-8s] %(host)s %(status)s %(product)s %(message)s' + + def apply_formatter(levelnum, formats, handler, color = False): + levelformdict = {} + for num in levelnum: + if num != logging.CRITICAL + 10: + levelformdict[num] = formats[0] + else: + levelformdict[num] = formats[1] + handler.setFormatter(LevelFormatter(levelformdict, color = color)) + return handler + + # Clear old handlers. + if log_obj.handlers: + log_obj.handlers = [] + for log_handler in log_handlers: log_handler.setLevel(config['loglevel']) - if log_handler.__class__.__name__ == 'StreamHandler': - log_handler.setFormatter(LevelFormatter(levelformdict, color = True)) - elif log_handler.__class__.__name__ == 'RotatingFileHandler': - log_handler.setFormatter(LevelFormatter(levelformdictcopy, color = False)) + if log_handler.name in ['LogStdout']: + log_handler = apply_formatter(levelnum, (frmt_std, frmt_min), log_handler, color = True) + elif log_handler.name in ['LogRotate']: + log_handler = apply_formatter(levelnum, (frmt_gen, frmt_min), log_handler) + # Attach. + if config['asyncmsg']: + log_obj.addHandler(MultiProcessingLogHandler('Thread-AsyncMsg{0}'.format(log_handler.name), handler = log_handler)) + else: + log_obj.addHandler(log_handler) - # Attach. log_obj.setLevel(config['loglevel']) - [ log_obj.addHandler(log_handler) for log_handler in log_handlers ] -#---------------------------------------------------------------------------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------------------------------------------------------------------------ def check_logfile(optionlog, defaultlog, where): if not isinstance(optionlog, list): optionlog = [optionlog] lenopt = len(optionlog) - msg_dir = "{reverse}{red}{bold}argument logfile: invalid directory: '%s'. Exiting...{end}" - msg_long = "{reverse}{red}{bold}argument logfile: too much arguments. Exiting...{end}" - msg_log = "{reverse}{red}{bold}argument logfile: not a log file, invalid extension: '%s'. Exiting...{end}" + msg_dir = "{reverse}{red}{bold}argument `-F/--logfile`: invalid directory: '%s'. Exiting...{end}" + msg_long = "{reverse}{red}{bold}argument `-F/--logfile`: too much arguments. Exiting...{end}" + msg_log = "{reverse}{red}{bold}argument `-F/--logfile`: not a log file, invalid extension: '%s'. Exiting...{end}" def checkdir(path): filename = os.path.basename(path) pathname = os.path.dirname(path) if not os.path.isdir(pathname): + if path.count('/') == 0: + pathname = filename pretty_printer(put_text = msg_dir %pathname, where = where, to_exit = True) elif not filename.lower().endswith('.log'): pretty_printer(put_text = msg_log %filename, where = where, to_exit = True) @@ -154,7 +248,7 @@ def check_logfile(optionlog, defaultlog, where): if lenopt > 2: pretty_printer(put_text = msg_long, where = where, to_exit = True) - if 'FILESTDOUT' in optionlog: + if (any(opt in ['FILESTDOUT', 'STDOUTOFF'] for opt in optionlog)): if lenopt == 1: # add default logfile. optionlog.append(defaultlog) @@ -164,12 +258,13 @@ def check_logfile(optionlog, defaultlog, where): else: if lenopt == 2: pretty_printer(put_text = msg_long, where = where, to_exit = True) - elif lenopt == 1 and 'STDOUT' not in optionlog: + elif lenopt == 1 and (any(opt not in ['STDOUT', 'FILEOFF'] for opt in optionlog)): # check directory path. checkdir(optionlog[0]) + return optionlog -#---------------------------------------------------------------------------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------------------------------------------------------------------------ # Valid language identifiers to be used in the EPID (see "kms.c" in vlmcsd) ValidLcid = [1025, 1026, 1027, 1028, 1029, @@ -208,21 +303,20 @@ def check_lcid(lcid, log_obj): fixlcid = next(k for k, v in locale.windows_locale.items() if v == locale.getdefaultlocale()[0]) except StopIteration: fixlcid = 1033 - pretty_printer(log_obj = log_obj, - put_text = "{reverse}{yellow}{bold}LCID %s auto-fixed with LCID %s{end}" %(lcid, fixlcid)) + pretty_printer(log_obj = log_obj, put_text = "{reverse}{yellow}{bold}LCID '%s' auto-fixed with LCID '%s'{end}" %(lcid, fixlcid)) return fixlcid return lcid -#---------------------------------------------------------------------------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------------------------------------------------------------------------ -class KmsException(Exception): +class KmsParserException(Exception): pass class KmsParser(argparse.ArgumentParser): def error(self, message): - raise KmsException(message) + raise KmsParserException(message) -class KmsHelper(object): +class KmsParserHelp(object): def replace(self, parser, replace_epilog_with): text = parser.format_help().splitlines() help_list = [] @@ -255,7 +349,126 @@ class KmsHelper(object): print(parser_base.epilog + '\n') parser_base.exit() -#---------------------------------------------------------------------------------------------------------------------------------------------------------- +def kms_parser_get(parser): + zeroarg, onearg = ([] for _ in range(2)) + act = vars(parser)['_actions'] + for i in range(len(act)): + if act[i].option_strings not in ([], ['-h', '--help']): + if isinstance(act[i], argparse._StoreAction): + onearg.append(act[i].option_strings) + else: + zeroarg.append(act[i].option_strings) + return zeroarg, onearg + +def kms_parser_check_optionals(userarg, zeroarg, onearg, msg = 'optional py-kms server', exclude_opt_len = []): + """ + For optionals arguments: + Don't allow duplicates, + Don't allow abbreviations, + Don't allow joining and not existing arguments, + Checks length values passed to arguments. + """ + zeroarg = [item for sublist in zeroarg for item in sublist] + onearg = [item for sublist in onearg for item in sublist] + allarg = zeroarg + onearg + + def is_abbrev(allarg, arg_to_check): + for opt in allarg: + if len(opt) > 2 and opt[2] == arg_to_check[2]: + for indx in range(-1, -len(opt), -1): + if opt[:indx] == arg_to_check: + raise KmsParserException("%s argument `%s` abbreviation not allowed for `%s`" %(msg, arg_to_check, opt)) + return False + + # Check abbreviations, joining, not existing. + for arg in userarg: + if arg not in allarg: + if arg.startswith('-'): + if arg == '--' or arg[:2] != '--' or not is_abbrev(allarg, arg): + raise KmsParserException("unrecognized %s arguments: `%s`" %(msg, arg)) + + # Check duplicates. + founds = [i for i in userarg if i in allarg] + dup = [item for item in set(founds) if founds.count(item) > 1] + if dup != []: + raise KmsParserException("%s argument `%s` appears several times" %(msg, ', '.join(dup))) + + # Check length. + elem = None + for found in founds: + if found not in exclude_opt_len: + pos = userarg.index(found) + try: + if found in zeroarg: + elem = userarg[pos + 1] + num = "zero arguments," + elif found in onearg: + elem = userarg[pos + 2] + num = "one argument," + except IndexError: + pass + + if elem and elem not in allarg: + raise KmsParserException("%s argument `" %msg + found + "`:" + " expected " + num + " unrecognized: '%s'" %elem) + +def kms_parser_check_positionals(config, parse_method, arguments = None, msg = 'positional py-kms server'): + try: + if arguments: + config.update(vars(parse_method(arguments))) + else: + config.update(vars(parse_method())) + except KmsParserException as e: + e = str(e) + if e.startswith('argument'): + raise + else: + raise KmsParserException("unrecognized %s arguments: '%s'" %(msg, e.split(': ')[1])) + +#------------------------------------------------------------------------------------------------------------------------------------------------------------ +def proper_none(dictionary): + for key in dictionary.keys(): + dictionary[key] = None if dictionary[key] == 'None' else dictionary[key] + +def check_setup(config, options, logger, where): + # 'None'--> None. + proper_none(config) + + # Check logfile. + config['logfile'] = check_logfile(config['logfile'], options['lfile']['def'], where = where) + + # Check logsize (py-kms Gui). + if config['logsize'] == "": + if any(opt in ['STDOUT', 'FILEOFF'] for opt in config['logfile']): + # set a recognized size never used. + config['logsize'] = 0 + else: + pretty_printer(put_text = "{reverse}{red}{bold}argument `-S/--logsize`: invalid with: '%s'. Exiting...{end}" %config['logsize'], + where = where, to_exit = True) + + # Check loglevel (py-kms Gui). + if config['loglevel'] == "": + # set a recognized level never used. + config['loglevel'] = 'ERROR' + + # Setup hidden / asynchronous messages. + hidden = ['STDOUT', 'FILESTDOUT', 'STDOUTOFF'] + view_flag = (False if any(opt in hidden for opt in config['logfile']) else True) + if where == 'srv': + ShellMessage.viewsrv = view_flag + ShellMessage.asyncmsgsrv = config['asyncmsg'] + elif where == 'clt': + ShellMessage.viewclt = view_flag + ShellMessage.asyncmsgclt = config['asyncmsg'] + + # Create log. + logger_create(logger, config, mode = 'a') + + # Check port. + if (config['port'] == "") or (not 1 <= config['port'] <= 65535): + pretty_printer(log_obj = logger.error, where = where, to_exit = True, + put_text = "{reverse}{red}{bold}Port number '%s' is invalid. Enter between 1 - 65535. Exiting...{end}" %config['port']) + +#------------------------------------------------------------------------------------------------------------------------------------------------------------ # http://joshpoley.blogspot.com/2011/09/hresults-user-0x004.html (slerror.h) ErrorCodes = { diff --git a/py-kms/pykms_Server.py b/py-kms/pykms_Server.py index ec83d23..cc99c13 100755 --- a/py-kms/pykms_Server.py +++ b/py-kms/pykms_Server.py @@ -27,12 +27,13 @@ except ImportError: import pykms_RpcBind, pykms_RpcRequest from pykms_RpcBase import rpcBase from pykms_Dcerpc import MSRPCHeader -from pykms_Misc import logger_create, check_logfile, check_lcid -from pykms_Misc import KmsParser, KmsException, KmsHelper -from pykms_Format import enco, deco, ShellMessage, pretty_printer +from pykms_Misc import check_setup, check_lcid +from pykms_Misc import KmsParser, KmsParserException, KmsParserHelp +from pykms_Misc import kms_parser_get, kms_parser_check_optionals, kms_parser_check_positionals +from pykms_Format import enco, deco, pretty_printer from Etrigan import Etrigan, Etrigan_parser, Etrigan_check, Etrigan_job -srv_version = "py-kms_2020-02-02" +srv_version = "py-kms_2020-07-01" __license__ = "The Unlicense" __author__ = u"Matteo ℱan " __url__ = "https://github.com/SystemRage/py-kms" @@ -148,12 +149,15 @@ class server_thread(threading.Thread): # Create and run server. self.server = server_create() self.server.pykms_serve() - except SystemExit as e: + except (SystemExit, Exception) as e: self.eject = True if not self.with_gui: raise else: - continue + if isinstance(e, SystemExit): + continue + else: + raise ##--------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -168,30 +172,30 @@ srv_options = { 'lcid' : {'help' : 'Use this option to manually specify an LCID for use with randomly generated ePIDs. Default is \"1033\" (en-us)', 'def' : 1033, 'des' : "lcid"}, 'count' : {'help' : 'Use this option to specify the current client count. A number >=25 is required to enable activation of client OSes; \ -for server OSes and Office >=5', 'def' : None, 'des' : "CurrentClientCount"}, +for server OSes and Office >=5', 'def' : None, 'des' : "clientcount"}, 'activation' : {'help' : 'Use this option to specify the activation interval (in minutes). Default is \"120\" minutes (2 hours).', - 'def' : 120, 'des': "VLActivationInterval"}, + 'def' : 120, 'des': "activation"}, 'renewal' : {'help' : 'Use this option to specify the renewal interval (in minutes). Default is \"10080\" minutes (7 days).', - 'def' : 1440 * 7, 'des' : "VLRenewalInterval"}, + 'def' : 1440 * 7, 'des' : "renewal"}, 'sql' : {'help' : 'Use this option to store request information from unique clients in an SQLite database. Desactivated by default.', 'def' : False, 'des' : "sqlite"}, 'hwid' : {'help' : 'Use this option to specify a HWID. The HWID must be an 16-character string of hex characters. \ The default is \"364F463A8863D35F\" or type \"RANDOM\" to auto generate the HWID.', 'def' : "364F463A8863D35F", 'des' : "hwid"}, - 'time' : {'help' : 'Max time (in seconds) for server to generate an answer. If \"None\" (default) serve forever.', 'def' : None, 'des' : "timeout"}, + 'time0' : {'help' : 'Maximum inactivity time (in seconds) after which the connection with the client is closed. If \"None\" (default) serve forever.', + 'def' : None, 'des' : "timeoutidle"}, + 'asyncmsg' : {'help' : 'Prints pretty / logging messages asynchronously. Desactivated by default.', + 'def' : False, 'des' : "asyncmsg"}, 'llevel' : {'help' : 'Use this option to set a log level. The default is \"ERROR\".', 'def' : "ERROR", 'des' : "loglevel", 'choi' : ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "MINI"]}, - 'lfile' : {'help' : 'Use this option to set an output log file. The default is \"pykms_logserver.log\". Type \"STDOUT\" to view \ -log info on stdout. Type \"FILESTDOUT\" to combine previous actions.', + 'lfile' : {'help' : 'Use this option to set an output log file. The default is \"pykms_logserver.log\". \ +Type \"STDOUT\" to view log info on stdout. Type \"FILESTDOUT\" to combine previous actions. \ +Use \"STDOUTOFF\" to disable stdout messages. Use \"FILEOFF\" if you not want to create logfile.', 'def' : os.path.join('.', 'pykms_logserver.log'), 'des' : "logfile"}, 'lsize' : {'help' : 'Use this flag to set a maximum size (in MB) to the output log file. Desactivated by default.', 'def' : 0, 'des': "logsize"}, } def server_options(): - try: - server_parser = KmsParser(description = srv_description, epilog = 'version: ' + srv_version, add_help = False, allow_abbrev = False) - except TypeError: - server_parser = KmsParser(description = srv_description, epilog = 'version: ' + srv_version, add_help = False) - + server_parser = KmsParser(description = srv_description, epilog = 'version: ' + srv_version, add_help = False) server_parser.add_argument("ip", nargs = "?", action = "store", default = srv_options['ip']['def'], help = srv_options['ip']['help'], type = str) server_parser.add_argument("port", nargs = "?", action = "store", default = srv_options['port']['def'], help = srv_options['port']['help'], type = int) server_parser.add_argument("-e", "--epid", action = "store", dest = srv_options['epid']['des'], default = srv_options['epid']['def'], @@ -199,88 +203,117 @@ def server_options(): server_parser.add_argument("-l", "--lcid", action = "store", dest = srv_options['lcid']['des'], default = srv_options['lcid']['def'], help = srv_options['lcid']['help'], type = int) server_parser.add_argument("-c", "--client-count", action = "store", dest = srv_options['count']['des'] , default = srv_options['count']['def'], - help = srv_options['count']['help'], type = int) + help = srv_options['count']['help'], type = str) server_parser.add_argument("-a", "--activation-interval", action = "store", dest = srv_options['activation']['des'], default = srv_options['activation']['def'], help = srv_options['activation']['help'], type = int) - server_parser.add_argument("-r", "--renewal-interval", action = "store", dest = srv_options['renewal']['des'], default = srv_options['renewal']['def'], - help = srv_options['renewal']['help'], type = int) - server_parser.add_argument("-s", "--sqlite", action = "store_const", dest = srv_options['sql']['des'], const = True, default = srv_options['sql']['def'], - help = srv_options['sql']['help']) + server_parser.add_argument("-r", "--renewal-interval", action = "store", dest = srv_options['renewal']['des'], + default = srv_options['renewal']['def'], help = srv_options['renewal']['help'], type = int) + server_parser.add_argument("-s", "--sqlite", action = "store_true", dest = srv_options['sql']['des'], + default = srv_options['sql']['def'], help = srv_options['sql']['help']) server_parser.add_argument("-w", "--hwid", action = "store", dest = srv_options['hwid']['des'], default = srv_options['hwid']['def'], help = srv_options['hwid']['help'], type = str) - server_parser.add_argument("-t", "--timeout", action = "store", dest = srv_options['time']['des'], default = srv_options['time']['def'], - help = srv_options['time']['help'], type = int) + server_parser.add_argument("-t0", "--timeout-idle", action = "store", dest = srv_options['time0']['des'], default = srv_options['time0']['def'], + help = srv_options['time0']['help'], type = str) + server_parser.add_argument("-y", "--async-msg", action = "store_true", dest = srv_options['asyncmsg']['des'], + default = srv_options['asyncmsg']['def'], help = srv_options['asyncmsg']['help']) server_parser.add_argument("-V", "--loglevel", action = "store", dest = srv_options['llevel']['des'], choices = srv_options['llevel']['choi'], default = srv_options['llevel']['def'], help = srv_options['llevel']['help'], type = str) - server_parser.add_argument("-F", "--logfile", nargs = "+", action = "store", dest = srv_options['lfile']['des'], default = srv_options['lfile']['def'], - help = srv_options['lfile']['help'], type = str) + server_parser.add_argument("-F", "--logfile", nargs = "+", action = "store", dest = srv_options['lfile']['des'], + default = srv_options['lfile']['def'], help = srv_options['lfile']['help'], type = str) server_parser.add_argument("-S", "--logsize", action = "store", dest = srv_options['lsize']['des'], default = srv_options['lsize']['def'], help = srv_options['lsize']['help'], type = float) + server_parser.add_argument("-h", "--help", action = "help", help = "show this help message and exit") - try: - daemon_parser = KmsParser(description = "daemon options inherited from Etrigan", add_help = False, allow_abbrev = False) - except TypeError: - daemon_parser = KmsParser(description = "daemon options inherited from Etrigan", add_help = False) - + daemon_parser = KmsParser(description = "daemon options inherited from Etrigan", add_help = False) daemon_subparser = daemon_parser.add_subparsers(dest = "mode") - try: - etrigan_parser = daemon_subparser.add_parser("etrigan", add_help = False, allow_abbrev = False) - except TypeError: - etrigan_parser = daemon_subparser.add_parser("etrigan", add_help = False) + + etrigan_parser = daemon_subparser.add_parser("etrigan", add_help = False) etrigan_parser.add_argument("-g", "--gui", action = "store_const", dest = 'gui', const = True, default = False, help = "Enable py-kms GUI usage.") etrigan_parser = Etrigan_parser(parser = etrigan_parser) try: - if "-h" in sys.argv[1:]: - KmsHelper().printer(parsers = [server_parser, daemon_parser, etrigan_parser]) + userarg = sys.argv[1:] + + # Run help. + if any(arg in ["-h", "--help"] for arg in userarg): + KmsParserHelp().printer(parsers = [server_parser, daemon_parser, etrigan_parser]) + + # Get stored arguments. + pykmssrv_zeroarg, pykmssrv_onearg = kms_parser_get(server_parser) + etrigan_zeroarg, etrigan_onearg = kms_parser_get(etrigan_parser) + pykmssrv_zeroarg += ['etrigan'] # add subparser # Set defaults for config. - # case: python3 pykms_Server.py + # example case: + # python3 pykms_Server.py srv_config.update(vars(server_parser.parse_args([]))) - # Eventually set daemon values for config. - if 'etrigan' in sys.argv[1:]: - if 'etrigan' == sys.argv[1]: - # case: python3 pykms_Server.py etrigan start --daemon_optionals - srv_config.update(vars(daemon_parser.parse_args(sys.argv[1:]))) - elif 'etrigan' == sys.argv[2]: - # case: python3 pykms_Server.py 1.2.3.4 etrigan start --daemon_optionals - srv_config['ip'] = sys.argv[1] - srv_config.update(vars(daemon_parser.parse_args(sys.argv[2:]))) - else: - # case: python3 pykms_Server.py 1.2.3.4 1234 --main_optionals etrigan start --daemon_optionals - knw_args, knw_extras = server_parser.parse_known_args() - # fix for logfile option (at the end) that catchs etrigan parser options. - if 'etrigan' in knw_args.logfile: - indx = knw_args.logfile.index('etrigan') - for num, elem in enumerate(knw_args.logfile[indx:]): - knw_extras.insert(num, elem) - knw_args.logfile = knw_args.logfile[:indx] - # continue parsing. - if len(knw_extras) > 0 and knw_extras[0] in ['etrigan']: - daemon_parser.parse_args(knw_extras, namespace = knw_args) - srv_config.update(vars(knw_args)) - else: - # Update dict config. - # case: python3 pykms_Server.py 1.2.3.4 1234 --main_optionals - knw_args, knw_extras = server_parser.parse_known_args() - if knw_extras != []: - raise KmsException("unrecognized arguments: %s" %' '.join(knw_extras)) - else: - srv_config.update(vars(knw_args)) + try: + # Eventually set daemon options for dict server config. + pos = sys.argv[1:].index('etrigan') + # example cases: + # python3 pykms_Server.py etrigan start + # python3 pykms_Server.py etrigan start --daemon_optionals + # python3 pykms_Server.py 1.2.3.4 etrigan start + # python3 pykms_Server.py 1.2.3.4 etrigan start --daemon_optionals + # python3 pykms_Server.py 1.2.3.4 1234 etrigan start + # python3 pykms_Server.py 1.2.3.4 1234 etrigan start --daemon_optionals + # python3 pykms_Server.py --pykms_optionals etrigan start + # python3 pykms_Server.py --pykms_optionals etrigan start --daemon_optionals + # python3 pykms_Server.py 1.2.3.4 --pykms_optionals etrigan start + # python3 pykms_Server.py 1.2.3.4 --pykms_optionals etrigan start --daemon_optionals + # python3 pykms_Server.py 1.2.3.4 1234 --pykms_optionals etrigan start + # python3 pykms_Server.py 1.2.3.4 1234 --pykms_optionals etrigan start --daemon_optionals - except KmsException as e: + kms_parser_check_optionals(userarg[0:pos], pykmssrv_zeroarg, pykmssrv_onearg, exclude_opt_len = ['-F', '--logfile']) + kms_parser_check_positionals(srv_config, server_parser.parse_args, arguments = userarg[0:pos]) + kms_parser_check_optionals(userarg[pos:], etrigan_zeroarg, etrigan_onearg, msg = 'optional etrigan') + kms_parser_check_positionals(srv_config, daemon_parser.parse_args, arguments = userarg[pos:], msg = 'positional etrigan') + + except ValueError: + # Update pykms options for dict server config. + # example cases: + # python3 pykms_Server.py 1.2.3.4 + # python3 pykms_Server.py 1.2.3.4 --pykms_optionals + # python3 pykms_Server.py 1.2.3.4 1234 + # python3 pykms_Server.py 1.2.3.4 1234 --pykms_optionals + # python3 pykms_Server.py --pykms_optionals + + kms_parser_check_optionals(userarg, pykmssrv_zeroarg, pykmssrv_onearg, exclude_opt_len = ['-F', '--logfile']) + kms_parser_check_positionals(srv_config, server_parser.parse_args) + + except KmsParserException as e: pretty_printer(put_text = "{reverse}{red}{bold}%s. Exiting...{end}" %str(e), to_exit = True) +class Etrigan_Check(Etrigan_check): + def emit_opt_err(self, msg): + pretty_printer(put_text = "{reverse}{red}{bold}%s{end}" %msg, to_exit = True) + +class Etrigan(Etrigan): + def emit_message(self, message, to_exit = False): + if not self.mute: + pretty_printer(put_text = "{reverse}{green}{bold}%s{end}" %message) + if to_exit: + sys.exit(0) + + def emit_error(self, message, to_exit = True): + if not self.mute: + pretty_printer(put_text = "{reverse}{red}{bold}%s{end}" %message, to_exit = True) + def server_daemon(): if 'etrigan' in srv_config.values(): path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'pykms_config.pickle') if srv_config['operation'] in ['stop', 'restart', 'status'] and len(sys.argv[1:]) > 2: - pretty_printer(put_text = "{reverse}{red}{bold}too much arguments. Exiting...{end}", to_exit = True) + pretty_printer(put_text = "{reverse}{red}{bold}too much arguments with etrigan '%s'. Exiting...{end}" %srv_config['operation'], + to_exit = True) + + # Check file arguments. + Etrigan_Check().checkfile(srv_config['etriganpid'], '--etrigan-pid', '.pid') + Etrigan_Check().checkfile(srv_config['etriganlog'], '--etrigan-log', '.log') if srv_config['gui']: pass @@ -311,14 +344,8 @@ def server_daemon(): Etrigan_job(srv_config['operation'], serverdaemon) def server_check(): - # Check logfile. - srv_config['logfile'] = check_logfile(srv_config['logfile'], srv_options['lfile']['def'], where = "srv") - - # Setup hidden or not messages. - ShellMessage.view = ( False if any(i in ['STDOUT', 'FILESTDOUT'] for i in srv_config['logfile']) else True ) - - # Create log. - logger_create(loggersrv, srv_config, mode = 'a') + # Setup and some checks. + check_setup(srv_config, srv_options, loggersrv, where = "srv") # Random HWID. if srv_config['hwid'] == "RANDOM": @@ -361,14 +388,30 @@ def server_check(): else: srv_config['dbSupport'] = True - # Check port. - if not 1 <= srv_config['port'] <= 65535: - pretty_printer(log_obj = loggersrv.error, to_exit = True, - put_text = "{red}{bold}Port number '%s' is invalid. Enter between 1 - 65535. Exiting...{end}" %srv_config['port']) + + # Check other specific server options. + list_dest = ['clientcount', 'timeoutidle'] + list_opt = ['-c/--client-count', '-t0/--timeout-idle'] + + if serverthread.with_gui: + list_dest += ['activation', 'renewal'] + list_opt += ['-a/--activation-interval', '-r/--renewal-interval'] + + for dest, opt in zip(list_dest, list_opt): + value = srv_config[dest] + if (value is not None) and (not isinstance(value, int)): + pretty_printer(log_obj = loggersrv.error, to_exit = True, + put_text = "{reverse}{red}{bold}argument `%s`: invalid with: '%s'. Exiting...{end}" %(opt, value)) def server_create(): - server = KeyServer((srv_config['ip'], srv_config['port']), kmsServerHandler) - server.timeout = srv_config['timeout'] + try: + server = KeyServer((srv_config['ip'], srv_config['port']), kmsServerHandler) + except (socket.gaierror, socket.error) as e: + pretty_printer(log_obj = loggersrv.error, to_exit = True, + put_text = "{reverse}{red}{bold}Connection failed '%s:%d': %s. Exiting...{end}" %(srv_config['ip'], + srv_config['port'], + str(e))) + server.timeout = srv_config['timeoutidle'] loggersrv.info("TCP server listening at %s on port %d." % (srv_config['ip'], srv_config['port'])) loggersrv.info("HWID: %s" % deco(binascii.b2a_hex(srv_config['hwid']), 'utf-8').upper()) return server @@ -423,20 +466,8 @@ def server_main_terminal(): def server_with_gui(): import pykms_GuiBase - width = 950 - height = 660 - root = pykms_GuiBase.KmsGui() - root.title(pykms_GuiBase.gui_description + ' ' + pykms_GuiBase.gui_version) - # Main window initial position. - ## https://stackoverflow.com/questions/14910858/how-to-specify-where-a-tkinter-window-opens - ws = root.winfo_screenwidth() - hs = root.winfo_screenheight() - x = (ws / 2) - (width / 2) - y = (hs / 2) - (height / 2) - root.geometry('+%d+%d' %(x, y)) - # disable maximize button. - root.resizable(0, 0) + root.title(pykms_GuiBase.gui_description + ' (' + pykms_GuiBase.gui_version + ')') root.mainloop() def server_main_no_terminal(): @@ -446,7 +477,7 @@ def server_main_no_terminal(): class kmsServerHandler(socketserver.BaseRequestHandler): def setup(self): - loggersrv.info("Connection accepted: %s:%d" % (self.client_address[0], self.client_address[1])) + loggersrv.info("Connection accepted: %s:%d" %(self.client_address[0], self.client_address[1])) def handle(self): while True: @@ -496,7 +527,7 @@ class kmsServerHandler(socketserver.BaseRequestHandler): def finish(self): self.request.close() - loggersrv.info("Connection closed: %s:%d" % (self.client_address[0], self.client_address[1])) + loggersrv.info("Connection closed: %s:%d" %(self.client_address[0], self.client_address[1])) serverqueue = Queue.Queue(maxsize = 0) diff --git a/wiki/Home.md b/wiki/Home.md new file mode 100644 index 0000000..e9b9a3e --- /dev/null +++ b/wiki/Home.md @@ -0,0 +1,40 @@ +Welcome to the _py-kms_ wiki !! + +## How To Use + +- [User Manual](https://github.com/SystemRage/py-kms/wiki/Manual) + - [Understanding KMS](https://github.com/SystemRage/py-kms/wiki/Manual#understanding-key-management-service) + - [About GVLK Keys](https://github.com/SystemRage/py-kms/wiki/Manual#about-gvlk-keys) + - [SLMGR and OSPP Commands](https://github.com/SystemRage/py-kms/wiki/Manual#slmgr-and-ospp-commands) + - [py-kms Usage](https://github.com/SystemRage/py-kms/wiki/Manual#py-kms-usage) + - [server.py Manual Start](https://github.com/SystemRage/py-kms/wiki/Manual#how-to-run-serverpy-manually) + - [server.py Auto Start](https://github.com/SystemRage/py-kms/wiki/Manual#how-to-run-serverpy-automatically-at-start) + - [server.py Options](https://github.com/SystemRage/py-kms/wiki/Manual#serverpy-options) + - [client.py Options](https://github.com/SystemRage/py-kms/wiki/Manual#clientpy-options) + - [Activation Procedure](https://github.com/SystemRage/py-kms/wiki/Manual#activation-procedure) + - [Windows](https://github.com/SystemRage/py-kms/wiki/Manual#windows) + - [Office](https://github.com/SystemRage/py-kms/wiki/Manual#office) + - [Supported Products](https://github.com/SystemRage/py-kms/wiki/Manual#supported-products) + - [Documentation](https://github.com/SystemRage/py-kms/wiki/Manual#documentation) + +## GVLK Keys + +- [Windows GVLK Keys](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys) + - [Windows Server 2019](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-server-2019) + - [Windows Server 2016](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-server-2016) + - [Windows 10](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-10) + - [Windows Server 2012 R2](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-server-2012-r2) + - [Windows 8.1](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-81) + - [Windows Server 2012](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-server-2012) + - [Windows 8](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-8) + - [Windows Server 2008 R2](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-server-2008-r2) + - [Windows 7](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-7) + - [Windows Server 2008](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-server-2008) + - [Windows Vista](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-vista) + - [Windows Previews](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys#windows-previews) + +- [Office GVLK Keys](https://github.com/SystemRage/py-kms/wiki/Office-GVLK-Keys) + - [Office 2019](https://github.com/SystemRage/py-kms/wiki/Office-GVLK-Keys#office-2019) + - [Office 2016](https://github.com/SystemRage/py-kms/wiki/Office-GVLK-Keys#office-2016) + - [Office 2013](https://github.com/SystemRage/py-kms/wiki/Office-GVLK-Keys#office-2013) + - [Office 2010](https://github.com/SystemRage/py-kms/wiki/Office-GVLK-Keys#office-2010) \ No newline at end of file diff --git a/wiki/Manual.md b/wiki/Manual.md new file mode 100644 index 0000000..9a122ee --- /dev/null +++ b/wiki/Manual.md @@ -0,0 +1,631 @@ +## Understanding Key Management Service +KMS activates Microsoft products on a local network, eliminating the need for individual computers to connect to Microsoft. To do this, KMS uses a client–server topology. KMS client locate KMS server by using DNS or a static configuration, then contact it by using Remote Procedure Call ( RPC ) and tries to activate against it. +KMS can activate both physical computers and virtual machines, but a network must meet or exceed the activation threshold ( minimum number of computers that KMS requires ). For activation, KMS clients on the network need to install a KMS client key ( General Volume License Key, GVLK ), so the product no longer asks Microsoft server but a user–defined server ( the KMS server ) which usually resides in a company’s intranet. + +_py-kms_ is a free open source KMS server emulator written in python, while Microsoft gives their KMS server only to corporations that signed a Select contract. Furthermore _py-kms_ never refuses activation since is without restrictions, while the Microsoft KMS server only activates the products the customer has paid for. + +_py-kms_ supports KMS protocol versions 4, 5 and 6. +Although _py-kms_ does neither require an activation key nor any payment, it is not meant to run illegal copies of Windows. Its purpose is to ensure that owners of legal copies can use their software without restrictions, +e.g. if you buy a new computer or motherboard and your key will be refused activation from Microsoft servers due to hardware changes. + +Activation with _py-kms_ is achieved with the following steps: +1. Run _py-kms_ on a computer in the network ( this is KMS server or local host ). +2. Install the product on client ( or said remote host, which is the computer sending data to local host ) and enter the GVLK. +3. Configure the client to use the KMS server. + +Note that KMS activations are valid for 180 days, the activation validity interval, or 30 / 45 days with consumer-only products. To remain activated, KMS client computers must renew their activation by connecting to the KMS server at least once every 180 days. +For this to work, should be to guarantee that a KMS server is always reachable for the clients on the network. +To remember you can't activate Windows 8.1 ( and above ) on a KMS server hosted on the same machine ( the KMS server must be a different computer than the client ). + +## About GVLK keys +The GVLK keys for products sold via volume license contracts ( renewal every 180 days ) are published on Microsoft’s Technet web site. + +* Windows: https://technet.microsoft.com/en-us/library/jj612867.aspx + +* Office 2010: https://technet.microsoft.com/en-us/library/ee624355(v=office.14).aspx#section2_3 + +* Office 2013: https://technet.microsoft.com/en-us/library/dn385360.aspx + +* Office 2016: https://technet.microsoft.com/it-it/library/dn385360(v=office.16).aspx + +There are also not official keys for consumer-only versions of Windows that require +activation renewal every 45 days ( Windows 8.1 ) or 30 days ( Windows 8 ). +More complete and well defined lists are available [here](https://github.com/SystemRage/py-kms/wiki/Windows-GVLK-Keys) and [here](https://github.com/SystemRage/py-kms/wiki/Office-GVLK-Keys). + +## SLMGR and OSPP commands +The software License Manager ( ```slmgr.vbs``` ) is a Visual Basic script used to configure and retrieve Volume Activation information. The script can be run locally or remotely on the target computer, using the Windows-based script host ( ```wscript.exe``` ) or the command-based script host ( ```cscript.exe``` ), and administrators can specify which script engine to use. If no script engine is specified, SLMGR runs using the default script engine ( note: it's recommended the cscript.exe script engine that resides in the system32 directory ). +The Software Licensing Service must be restarted for any changes to take effect. To restart it, can be used the Microsoft Management Console ( MMC ) Services or running the following command: + +```net stop sppsvc && net start sppsvc``` + +The _SLMGR_ requires at least one parameter. If the script is run without any parameters, it displays Help information. The general syntax of ```slmgr.vbs``` is as follows ( using the ```cscript.exe``` as the script engine ): + +``` +cscript slmgr.vbs /parameter +cscript slmgr.vbs [ComputerName] [User] [Password] [Option] +``` +where command line options are: +``` +[ComputerName] Name of a remote computer ( default is local computer ). +[User] Account with the required privilege on the remote computer. +[Password] Password for the account with required privileges on the remote compute. +[Option] Options are shown in the table below. +``` + +Following tables lists _SLMGR_ more relevant options and a brief description of each. Most of the parameters configure the KMS host. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Global optionsDescription
/ipk <ProductKey>Attempts to install a 5×5 ProductKey for Windows or other application identified by the ProductKey. If the key is valid, this is installed. If a key is already installed, it's silently replaced.
/ato [ActivationID]Prompts Windows to attempt online activation, for retail and volume systems with KMS host key. Specifying the ActivationID parameter isolates the effects of the option to the edition associated with that value.
/dli [ActivationID | All]Display license information. Specifying the ActivationID parameter displays the license information for the specified edition associated with that ActivationID. Specifying All will display all applicable installed products’ license information. Useful for retrieve the current KMS activation count from the KMS host.
/dlv [ActivationID | All]Display detailed license information.
/xpr [ActivationID]Display the activation expiration date for the current license state.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Advanced optionsDescription
/cpkySome servicing operations require the product key to be available in the registry during Out-of-Box Experience ( OOBE ) operations. So this option removes the product key from the registry to prevent from being stolen by malicious code.
/ilc <LicenseFile>Installs the LicenseFile specified by the required parameter.
/rilcReinstalls all licenses stored in %SystemRoot%\system32\oem and %SystemRoot%\System32\spp\tokens.
/rearmResets the activation timers.
/rearm-app <ApplicationID>Resets the licensing status of the specified application.
/rearm-sku <ApplicationID>Resets the licensing status of the specified SKU.
/upk [ActivationID]Uninstalls the product key of the current Windows edition. After a restart, the system will be in an unlicensed state unless a new product key is installed.
/dti [ActivationID]Displays installation ID for offline activation of the KMS host for Windows ( default ) or the application that is identified when its ActivationID is provided.
/atp [ConfirmationID][ActivationID]Activate product with user-provided ConfirmationID.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KMS client optionsDescription
/skms <Name[:Port] | : port> [ActivationID]Specifies the name and the port of the KMS host computer to contact. Setting this value disables auto-detection of the KMS host. If the KMS host uses IPv6 only, the address must be specified in the format [hostname]:port.
/skms-domain <FQDN> [ActivationID]Sets the specific DNS domain in which all KMS SRV records can be found. This setting has no effect if the specific single KMS host is set with the /skms option. Use this option, especially in disjoint namespace environments, to force KMS to ignore the DNS suffix search list and look for KMS host records in the specified DNS domain instead.
/ckms [ActivationID]Removes the specified KMS hostname, address, and port information from the registry and restores KMS auto-discovery behavior.
/skhcEnables KMS host caching ( default ), which blocks the use of DNS priority and weight after the initial discovery of a working KMS host. If the system can no longer contact the working KMS host, discovery will be attempted again.
/ckhcDisables KMS host caching. This setting instructs the client to use DNS auto-discovery each time it attempts KMS activation ( recommended when using priority and weight ).
/sai <ActivationInterval>Changes how often a KMS client attempts to activate itself when it cannot find a KMS host. Replace ActivationInterval with a number of minutes between 15 minutes an 30 days. The default setting is 120.
/sri <RenewalInterval>Changes how often a KMS client attempts to renew its activation by contacting a KMS host. Replace RenewalInterval with a number of minutes between 15 minutes an 30 days. The default setting is 10080 ( 7 days ).
/sprt <PortNumber>Sets the TCP communications port on a KMS host. It replaces PortNumber with the TCP port number to use. The default setting is 1688.
/sdnsEnables automatic DNS publishing by the KMS host.
/cdnsDisables automatic DNS publishing by a KMS host.
/spriSets the priority of KMS host processes to Normal.
/cpriSet the KMS priority to Low.
/act-type [ActivationType] [ActivationID]Sets a value in the registry that limits volume activation to a single type. ActivationType 1 limits activation to active directory only; 2 limits it to KMS activation; 3 to token-based activation. The 0 option allows any activation type and is the default value.
+ +The Office Software Protection Platform script ( ```ospp.vbs``` ) can help you to configure and test volume license editions of Office client products. +You must open a command prompt by using administrator permissions and navigate to the folder that contains the script. The script is located in the folder of Office installation ( ```\Office14``` for Office 2010, ```\Office15``` for Office 2013, ```\Office16``` for Office 2016 ): + +```%installdir%\Program Files\Microsoft Office\Office15```. + +If you are running 32-bit Office on a 64-bit operating system, the script is located in the folder: + +```%installdir%\Program Files (x86)\Microsoft Office\Office15```. + +Running _OSPP_ requires the ```cscript.exe``` script engine. To see the Help file, type the following command, and then press ENTER: + +```cscript ospp.vbs /?```. + +The general syntax is as follows: + +```cscript ospp.vbs [Option:Value] [ComputerName] [User] [Password]```, + +where command line options are: +``` +[Option:Value] Specifies the option and Value to use to activate a product, install or uninstall a product key, install and display license information, set KMS host name and port, and remove KMS host. The options and values are listed in the tables below. +[ComputerName] Name of the remote computer. If a computer name is not provided, the local computer is used. +[User] Account that has the required permission on the remote computer. +[Password] Password for the account. If a user account and password are not provided, the current credentials are used. +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Global optionsDescription
/actActivates installed Office product keys.
/inpkey:<ProductKey>Installs a ProductKey ( replaces existing key ) with a user-provided ProductKey.
/unpkey:<ProductKey>Uninstalls an installed ProductKey with the last five digits of the ProductKey to uninstall ( as displayed by the /dstatus option ).
/inslic:<LicenseFile>Installs a LicenseFile with user-provided path of the .xrm-ms license.
/dstatusDisplays license information for installed product keys.
/dstatusallDisplays license information for all installed licenses.
/dhistoryacterrDisplays the failure history for MAK / Retail activation.
/dinstidDisplays Installation ID for offline activation.
/actcid:<ConfirmationID>Activates product with user-provided ConfirmationID.
/rearmResets the licensing status for all installed Office product keys.
/rearm:<ApplicationID>Resets the licensing status for an Office license with a user-provided SKUID value. Use this option with the SKUID value specified by using the /dstatus option if you have run out of rearms and have activated Office through KMS or Active Directory-based activation to gain an additional rearm.
/ddescr:<ErrorCode>Displays the description for a user-provided ErrorCode.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KMS client optionsDescription
/dhistorykmsDisplays KMS client activation history.
/dcmidDisplays KMS client computer ID ( CMID )
/sethst:<HostName>Sets a KMS host name with a user-provided HostName.
/setprt:<Port>Sets a KMS port with a user-provided Port number.
/remhstRemoves KMS hostname ( sets port to default ).
/cachst:<Value>Allows or denies KMS host caching. Parameter Value can be TRUE or FALSE.
/actype:<Value>( Windows 8 and later only ) Sets volume activation type. Parameter Value can be: 1 ( for Active Directory-based ), 2 ( for KMS ), 0 ( for both ).
/skms-domain:<Value>( Windows 8 and later only ) Sets the specific DNS domain in which all KMS SRV records can be found. This setting has no effect if the specific single KMS host is set by the /sethst option. Parameter Value is the Fully Qualified Domain Name ( FQDN ).
/ckms-domain( Windows 8 and later only ) Clears the specific DNS domain in which all KMS SRV records can be found. The specific KMS host is used if it is set by the /sethst option. Otherwise, auto-discovery of the KMS host is used.
+ +## py-kms Usage + +#### _How to run pykms_Server.py manually_. +*** +A Linux user with ```ifconfig``` command can get his KMS IP ( Windows users can try ```ipconfig /all```). +``` +user@user ~ $ ifconfig +eth0 Link encap: Ethernet HWaddr xx:xx:xx:xx..... + inet addr: 192.168.1.102 Bcast 192.168.1.255 Mask: 255.255.255.0 + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX Packets: 6 errors: 0 dropped, etc.. 0 + TX packets: 3 errors:0, etc.. 0 + colisions: 0 txqueuelen: 1000 + RX bytes: 1020 TX Bytes: 708 + +lo Link encap: Local Loopback + inet addr: 127.0.0.1 Mask 255.0.0.0 + UP Loopback running MTU: 65536 Metric: 1 + RX packets 4: errors: 0 etc 0 + TX packets 4: errors: 0 etc 0 +``` +In the example above is 192.168.1.102, so is valid: + +```user@user ~/path/to/folder/py-kms $ python pykms_Server.py 192.168.1.102 1688``` + +To stop _pykms_Server.py_, in the same bash window where code running, simply press CTRL+C. +Alternatively, in a new bash window, use ```kill ``` command ( you can type ```ps aux``` first and have the process ) or ```killall ```. + +#### _How to run pykms_Server.py automatically at start_. +*** +If you are running a Linux distro that is using ```upstart```, you can simply manage a daemon that runs as a background process. + +```sudo nano /etc/init/py-kms.conf``` + +Then add the following ( changing where necessary ) and save file: +``` +description "py-kms" +author "SystemRage" +env PYTHON_HOME=/ +env PATH=$PYTHON_HOME:$PATH +start on runlevel [2345] +stop on runlevel [016] +chdir /home/user/path/to/py-kms +exec $PYTHON_HOME/bin/python pykms_Server.py -v DEBUG --logfile /var/log/pykms_logserver.log +respawn +``` +Confirm that it looks ok with: ```init-checkconf /etc/init/py-kms.conf``` and reload configuration: ```initctl reload-configuration``` + +Now reboot the machine ```sudo reboot``` and when you boot up your system, you can see the log file stating that your daemon is running : + +```cat /var/log/pykms_logserver.log```. + +Finally a few commands useful for the status of your daemon: +* restart --> this will stop, then start a service: ```sudo service py-kms restart``` +* start --> this will start a service, if it's not running: ```sudo service py-kms start``` +* stop --> this will stop a service, if it's running: ```sudo service py-kms stop``` +* status --> this will display the status of a service: ```sudo service py-kms status``` + +According to OS that you are running, you can also create a daemon with ```systemd``` or ```SysV```. + +If you are using Windows, to run _pykms_Server.py_ as service you need to install [pywin32](https://sourceforge.net/projects/pywin32/) then you can create a file for example named _kms-winservice.py_ and put into it this code: + +``` +import win32serviceutil +import win32service +import win32event +import servicemanager +import socket +import subprocess + +class AppServerSvc (win32serviceutil.ServiceFramework): + _svc_name_ = "py-kms" + _svc_display_name_ = "py-kms" + _proc = None + _cmd = ["C:\Windows\Python27\python.exe", "C:\Windows\Python27\py-kms\pykms_Server.py"] + + def __init__(self,args): + win32serviceutil.ServiceFramework.__init__(self,args) + self.hWaitStop = win32event.CreateEvent(None,0,0,None) + socket.setdefaulttimeout(60) + + def SvcStop(self): + self.killproc() + self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) + win32event.SetEvent(self.hWaitStop) + + def SvcDoRun(self): + servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, + servicemanager.PYS_SERVICE_STARTED, + (self._svc_name_,'')) + self.main() + + def main(self): + self._proc = subprocess.Popen(self._cmd) + self._proc.wait() + + def killproc(self): + self._proc.kill() + +if __name__ == '__main__': + win32serviceutil.HandleCommandLine(AppServerSvc) +``` +Now in a command prompt type ```C:\Windows\Python27\python.exe kms-winservice.py install``` to install the service. +Display all the services with ```services.msc``` and find the service associated with _py-kms_, changing startup type from "manual" to "auto". Finally "Start" the service. +If this approach fails, you can try to use the [Non-Sucking Service Manager](https://nssm.cc/) or Task Scheduler as described [here](https://blogs.esri.com/esri/arcgis/2013/07/30/scheduling-a-scrip/). + +#### _pykms_Server.py Options_. +*** +Follows a list of usable parameters: + + ip + Instructs py-kms to listen on IPADDRESS ( can be an hostname too ). If this option is + not specified, IPADDRESS 0.0.0.0 is used. + + port + Define TCP PORT the KMS service is listening on. Default is 1688. + + -e or --epid + Use EPID as Windows EPID. + Enhanced Privacy ID ( EPID ) is a cryptographic scheme for providing anonymous signatures. + If no EPID is specified, a random EPID will be generated. + + -l or --lcid + Do not randomize the locale ID part of the EPID and use LCID instead. + The Language Code Identifier ( LCID ) describes localizable information in Windows. + This structure is used to identify specific languages for the purpose of customizing + software for particular languages and cultures. For example, it can specify the way dates, + times, and numbers are formatted as strings. It can also specify paper sizes and + preferred sort order based on language elements. + The LCID must be specified as a decimal number ( example: 1049 for "Russian - Russia" ). + By default py-kms generates a valid locale ID but this may lead to a value which is + unlikely to occur in your country. You may want to select the locale ID of your country instead. + See + https://msdn.microsoft.com/en-us/library/cc233982.aspx + for a list of valid LCIDs. Note that some of them are not recognized by .NET Framework 4.0. + If an EPID is manually specified, this setting is ignored. + Default is a fixed LCID of 1033 ( English - US ). + + -w or --hwid + Use specified HWID for all products. + Hardware Identification is a security measure used by Microsoft upon the activation of + the Windows operating system. As part of the Product Activation system, a unique + HWID number is generated when the operating system is first installed. The HWID identifies + the hardware components that the system is utilizing, and this number is communicated to Microsoft. + Every 10 days and at every reboot the operating system will generate another HWID number and + compare it to the original to make sure that the operating system is still running on the same device. + If the two HWID numbers differ too much then the operating system will shut down until Microsoft + reactivates the product. The theory behind HWID is to ensure that the operating system is not being + used on any device other than the one for which it was purchased and registered. + + HWID must be an 16-character string of hex characters that are interpreted as a series of 8 bytes + ( big endian ). Default is "364F463A8863D35F". To auto generate the HWID, type "random". + + -c or --client-count + Use this flag to specify the current CLIENTCOUNT. Default is None. Remember that a number >=25 is + required to enable activation of client OSes while for server OSes and Office >=5. + + -a or --activation-interval + Instructs clients to retry activation every ACTIVATIONINTERVAL minutes if it was unsuccessful, + e.g. because it could not reach the server. The default is 120 minutes ( 2 hours ). + + -r or --renewal-interval + Instructs clients to renew activation every RENEWALINTERVAL minutes. + The default is 10080 minutes ( 7 days ). + + -s or --sqlite + Use this option to store request information from unique clients in an SQLite database. + + -t or --timeout + Disconnect clients after time of inactivity ( in seconds ). The default is 30 seconds. + + -V or --loglevel <{CRITICAL, ERROR, WARNING, INFO, DEBUG, MINI}> + Activate verbose logging. Use this flag to set a loglevel. The default is ERROR. + + ( example: user@user ~/path/to/folder/py-kms $ python pykms_Server.py -V INFO + produces in "pykms_logserver.log" these initial messages: + Mon, 12 Jun 2017 22:09:00 INFO TCP server listening at 0.0.0.0 on port 1688. + Mon, 12 Jun 2017 22:09:00 INFO HWID: 364F463A8863D35F ) + + -F or --logfile + Create a "LOGFILE.log" logging file. The default is named "pykms_logserver.log". + + ( example: user@user ~/path/to/folder/py-kms $ python pykms_Server.py 192.168.1.102 8080 + -F ~/path/to/folder/py-kms/newfile.log -V INFO -w random + produces in "newfile.log" these initial messages: + Mon, 12 Jun 2017 22:09:00 INFO TCP server listening at 192.168.1.102 on port 8080. + Mon, 12 Jun 2017 22:09:00 INFO HWID: 58C4F4E53AE14224 ) + + -S or --logsize + Use this flag to set a maximum size ( in MB ) to the output log file. Desactivated by default. + +#### _pykms_Client.py Options_. +*** +If something does not work, it may have the cause that _py-kms_ server does not work correctly. You can test this with the KMS client _pykms_Client.py_, running on the same machine where you started _pykms_Server.py_. +For example ( in separated bash windows ) run these commands: +``` +user@user ~/path/to/folder/py-kms $ python pykms_Server.py -V DEBUG +user@user ~/path/to/folder/py-kms $ python pykms_Client.py 0.0.0.0 1688 -V DEBUG +``` +or if you want better specify: +``` +user@user ~/path/to/folder/py-kms $ python pykms_Server.py YOUR_IPADDRESS 1688 -V DEBUG +user@user ~/path/to/folder/py-kms $ python pykms_Client.py YOUR_IPADDRESS 1688 -V DEBUG +``` +You can also put further parameters as defined below: + + ip + Define IPADDRESS ( or hostname ) of py-kms' KMS Server. This parameter is always required. + + port + Define TCP PORT the KMS service is listening on. Default is 1688. + + -m or --mode + Use this flag to manually specify a Microsoft PRODUCTNAME for testing the KMS server. + The default is Windows81. + + -c or --cmid + Use this flag to manually specify a CMID to use. If no CMID is specified, a random one + will be generated. + The Microsoft KMS host machine identifies KMS clients with a unique Client Machine ID + ( CMID, example: ae3a27d1-b73a-4734-9878-70c949815218 ). For a KMS client to successfully + activate, the KMS server needs to meet a threshold, which is a minimum count for KMS clients. + Once a KMS server records a count which meets or exceeds threshold, KMS clients will begin to + activate successfully. Each unique CMID recorded by KMS server adds towards the count threshold + for KMS clients. This are retained by the KMS server for a maximum of 30 days after the + last activation request with that CMID. Note that duplicate CMID only impacts on KMS server + machine count of client machines. Once KMS server meets minimum threshold, KMS clients will + activate regardless of CMID being unique for a subset of specific machines or not. + + -n or --name + Use this flag to manually specify an ASCII MACHINENAME to use. If no MACHINENAME is specified + a random one will be generated. + + -V or --loglevel <{CRITICAL, ERROR, WARNING, INFO, DEBUG, MINI}> + Activate verbose logging. Use this flag to set a loglevel. The default is ERROR. + + -F of --logfile + Create a "LOGFILE.log" logging file. The default is named "pykms_logclient.log". + + -S or --logsize + Use this flag to set a maximum size ( in MB ) to the output log file. Desactivated by default. + +## Activation Procedure +Briefly the product asks for a key during installation, so it needs to enter the GVLK. Then user can set connection parameters, while KMS server must already be running on server machine. Finally with specific commands activation occurs automatically and can be extended later every time for another 180 ( or 45 ) days. + +#### _Windows_ +*** +![win1](https://user-images.githubusercontent.com/25354386/36869547-74d05076-1d9c-11e8-9dee-1ff641449c7c.png) + +![win2](https://user-images.githubusercontent.com/25354386/36871704-5f62dda6-1da3-11e8-91f7-a7bc71670926.png) + +0. Run a Command Prompt as Administrator ( you are directly in ```C:\Windows\System32``` path ). + +```//nologo``` option of ```cscript``` needs only to hide startup logo. + +1. This is facoltative, it's for unistalling existing product key. +2. Then put your product's GVLK. +3. Set connection parameters. +4. Try online activation, but... if that fails with error ```0xC004F074``` you’ll most likely have to configure your firewall that it accepts incoming connections on TCP port 1688. +So for Linux users ( server-side with pykms_Server.py running ): ```sudo ufw allow 1688``` ( to remove this rule ```sudo ufw delete allow 1688``` ) +5. Attempt online activation ( with now traffic on 1688 enabled ). +6. View license informations ( facoltative ). + +#### _Office_ +*** +Note that you’ll have to install a volume license ( VL ) version of Office. Office versions downloaded from MSDN and / or Technet are non-VL. + +![off1](https://user-images.githubusercontent.com/25354386/36871724-6e9e5958-1da3-11e8-8c09-8fd693b20c52.png) + +![off2](https://user-images.githubusercontent.com/25354386/36871740-79ce2ae2-1da3-11e8-9ef1-d9b14b86364c.png) + +![off3](https://user-images.githubusercontent.com/25354386/36871754-84fa99e6-1da3-11e8-907b-f9435acd3a2d.png) + +![off4](https://user-images.githubusercontent.com/25354386/36871764-8e179e2a-1da3-11e8-8e37-eb138a988dea.png) + +0. Run a Command Prompt as Administrator and navigate to Office folder ```cd C:\ProgramFiles\Microsoft Office\OfficeXX``` (64-bit path) or ```cd C:\ProgramFiles(x86)\Microsoft Office\OfficeXX``` (32-bit path), where XX = 14 for Office 2010, 15 for Office 2013, 16 for Office 2016 or Office 2019. +1. As you can see, running ```/dstatus```, my Office is expiring ( 14 days remaining ). +2. Only for example, let's go to uninstall this product. +3. This is confirmed running ```/dstatus``` again. +4. Now i put my product's GVLK ( and you your key ). +5. Set the connection parameter KMS server address. +6. Set the connection parameter KMS server port. +7. Activate installed Office product key. +8. View license informations ( in my case product is now licensed and remaining grace 180 days as expected ). + +## Supported Products +Note that it is possible to activate all versions in the VL ( Volume License ) channel, so long as you provide the proper key to let Windows know that it should be activating against a KMS server. KMS activation can't be used for Retail channel products, however you can install a VL product key specific to your edition of Windows even if it was installed as Retail. This effectively converts Retail installation to VL channel and will allow you to activate from a KMS server. This is not valid for Office's products, so Office, Project and Visio must be volume license versions. Newer version may work as long as the KMS protocol does not change. + +## Documentation +* [1] https://forums.mydigitallife.net/threads/emulated-kms-servers-on-non-windows-platforms.50234 +* [2] https://forums.mydigitallife.net/threads/discussion-microsoft-office-2019.75232 +* [3] https://forums.mydigitallife.net/threads/miscellaneous-kms-related-developments.52594 +* [4] https://forums.mydigitallife.net/threads/kms-activate-windows-8-1-en-pro-and-office-2013.49686 +* [5] https://github.com/myanaloglife/py-kms +* [6] https://github.com/Wind4/vlmcsd +* [7] https://github.com/ThunderEX/py-kms +* [8] https://github.com/CNMan/balala/blob/master/pkconfig.csv +* [9] http://www.level7techgroup.com/docs/kms_overview.pdf +* [10] https://www.dell.com/support/article/it/it/itbsdt1/sln266176/windows-server-using-the-key-management-service-kms-for-activation-of-volume-licensed-systems?lang=en +* [11] https://social.technet.microsoft.com/Forums/en-US/c3331743-cba2-4d92-88aa-9633ac74793a/office-2010-kms-current-count-remain-at-10?forum=officesetupdeployprevious +* [12] https://betawiki.net/wiki/Microsoft_Windows +* [13] https://thecollectionbook.info/builds/windows +* [14] https://www.betaarchive.com/forum/viewtopic.php%3Ft%3D29131+&cd=10&hl=it&ct=clnk&gl=it +* [15] https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=12&cad=rja&uact=8&ved=2ahUKEwjmvZihtOHeAhVwyoUKHSjeD5Q4ChAWMAF6BAgHEAI&url=ftp%3A%2F%2Flynas.ittc.vu.lt%2Fpub%2FMicrosoft%2FWindows%2520Vista%2FWindows%2520Vista_Volume_Activation_2.0%2FWindows%2520Vista%2520Volume%2520Activation%2FWindows%2520Vista_Volume_Activation_2.0%2Fvolume%2520activation%25202%25200%2520step-by-step%2520guide.doc&usg=AOvVaw3kqhCu3xT-3r416DRGUUs_ +* [16] https://www.itprotoday.com/windows-78/volume-activation-server-2008 +* [17] https://docs.microsoft.com/en-us/windows-server/get-started-19/activation-19 +* [18] https://docs.microsoft.com/en-us/windows-server/get-started/windows-server-release-info +* [19] https://support.microsoft.com/en-us/help/13853/windows-lifecycle-fact-sheet \ No newline at end of file diff --git a/wiki/Office-GVLK-Keys.md b/wiki/Office-GVLK-Keys.md new file mode 100644 index 0000000..2eb6afb --- /dev/null +++ b/wiki/Office-GVLK-Keys.md @@ -0,0 +1,136 @@ +### _Office 2019_ + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Professional Plus 2019 [C2R]VQ9DP-NVHPH-T9HJC-J9PDT-KTQRG
Professional Plus 2019NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP
Standard 20196NWWJ-YQWMR-QKGCB-6TMB3-9D9HK
Project Professional 2019 [C2R]XM2V9-DN9HH-QB449-XDGKC-W2RMW
Project Professional 2019B4NPR-3FKK7-T2MBV-FRQ4W-PKD2B
Project Standard 2019C4F7P-NCP8C-6CQPT-MQHV9-JXD2M
Visio Professional 2019 [C2R]N2CG9-YD3YK-936X4-3WR82-Q3X4H
Visio Professional 20199BGNQ-K37YR-RQHF2-38RQ3-7VCBB
Visio Standard 20197TQNQ-K3YQQ-3PFH7-CCPPM-X4VQ2
Access 20199N9PT-27V4Y-VJ2PD-YXFMF-YTFQT
Excel 2019TMJWT-YYNMB-3BKTF-644FC-RVXBD
Outlook 20197HD7K-N4PVK-BHBCQ-YWQRW-XW4VK
PowerPoint 2019RRNCX-C64HY-W2MM7-MCH9G-TJHMQ
Publisher 2019G2KWX-3NW6P-PY93R-JXK2T-C9Y9V
Skype for Business 2019NCJ33-JHBBY-HTK98-MYCV8-HMKHJ
Word 2019PBX3G-NWMT6-Q7XBW-PYJGG-WXD33
+ +### _Office 2016_ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Professional Plus 2016XQNVK-8JYDB-WJ9W3-YJ8YR-WFG99
Standard 2016JNRGM-WHDWX-FJJG3-K47QV-DRTFM
Project Professional 2016YG9NW-3K39V-2T3HJ-93F3Q-G83KT
Project Professional 2016 [C2R]WGT24-HCNMF-FQ7XH-6M8K7-DRTW9
Project Standard 2016GNFHQ-F6YQM-KQDGJ-327XX-KQBVC
Project Standard 2016 [C2R]D8NRQ-JTYM3-7J2DX-646CT-6836M
Visio Professional 2016PD3PC-RHNGV-FXJ29-8JK7D-RJRJK
Visio Professional 2016 [C2R]69WXN-MBYV6-22PQG-3WGHK-RM6XC
Visio Standard 20167WHWN-4T7MP-G96JF-G33KR-W8GF4
Visio Standard 2016 [C2R]NY48V-PPYYH-3F4PX-XJRKJ-W4423
Access 2016GNH9Y-D2J4T-FJHGG-QRVH7-QPFDW
Excel 20169C2PK-NWTVB-JMPW8-BFT28-7FTBF
Mondo 2016HFTND-W9MK4-8B7MJ-B6C4G-XQBR2
Mondo Retail 2016DMTCJ-KNRKX-26982-JYCKT-P7KB6
OneNote 2016DR92N-9HTF2-97XKM-XW2WJ-XW3J6
Outlook 2016R69KK-NTPKF-7M3Q4-QYBHW-6MT9B
PowerPoint 2016J7MQP-HNJ4Y-WJ7YM-PFYGF-BY6C6
Publisher 2016F47MM-N3XJP-TQXJ9-BP99D-8K837
Skype for Business 2016869NQ-FJ69K-466HW-QYCP2-DDBV6
Word 2016WXY84-JN2Q9-RBCCQ-3Q3J3-3PFJ6
+ +### _Office 2013_ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Professional Plus 2013 [Preview]PGD67-JN23K-JGVWV-KTHP4-GXR9G
Professional Plus 2013YC7DK-G2NP3-2QQC3-J6H88-GVGXT
Standard 2013KBKQT-2NMXY-JJWGP-M62JB-92CD4
Project Professional 2013 [Preview]NFKVM-DVG7F-TYWYR-3RPHY-F872K
Project Professional 2013FN8TT-7WMH6-2D4X9-M337T-2342K
Project Standard 2013 [Preview]N89QF-GGB8J-BKD28-C4V28-W4XTK
Project Standard 20136NTH3-CW976-3G3Y2-JK3TX-8QHTT
Visio Professional 2013 [Preview]B3C7Q-D6NH2-2VRFW-HHWDG-FVQB6
Visio Professional 2013C2FG9-N6J68-H8BTJ-BW3QX-RM3B3
Visio Standard 2013 [Preview]9MKNF-J9XQ6-JV4XB-FJQPY-43F43
Visio Standard 2013J484Y-4NKBF-W2HMG-DBMJC-PGWR7
Access 2013 [Preview]DJBH8-RGN7Q-836KD-DMP3M-DM9MF
Access 2013NG2JY-H4JBT-HQXYP-78QH9-4JM2D
Excel 2013 [Preview]Q3BNP-3WXDT-GG8HF-24KMW-HMDBK
Excel 2013VGPNG-Y7HQW-9RHP7-TKPV3-BG7GB
OneNote 2013 [Preview]VYNYX-8GPBC-7FQMD-D6B7B-7MDFD
OneNote 2013TGN6P-8MMBC-37P2F-XHXXK-P34VW
Outlook 2013 [Preview]X2KNB-FRRG2-WXDPH-739DM-DM9RH
Outlook 2013QPN8Q-BJBTJ-334K3-93TGY-2PMBT
PowerPoint 2013 [Preview]B8CT8-BTNFQ-XQXBK-BFWV8-HMDFQ
PowerPoint 20134NT99-8RJFH-Q2VDH-KYG2C-4RD4F
Publisher 2013 [Preview]NB67P-J8XP4-XDK9B-V73VH-M4CKR
Publisher 2013PN2WF-29XG2-T9HJ7-JQPJR-FCXK4
InfoPath 2013 (Preview)7KPJJ-N8TT7-CK3KR-QTV98-YPVXQ
InfoPath 2013DKT8B-N7VXH-D963P-Q4PHY-F8894
Lync 2013 [Preview]XNVD3-RYC7T-7R6BT-WX6CF-8BYH7
Lync 20132MG3G-3BNTT-3MFW9-KDQW3-TCK7R
Word 2013 [Preview]JBGD4-3JNG7-JWWGV-CR6TP-DC62Q
Word 20136Q7VD-NX8JD-WJ2VH-88V73-4GBJ7
Mondo 2013 [Preview]GCGCN-6FJRM-TR9Q3-BGMWJ-78KQV
Mondo 201342QTK-RN8M7-J3C4G-BBGYM-88CYV
Mondo 2013 Retail?????-?????-?????-?????-?????
SharePoint Workspace (Groove) 2013 [Preview]WVCGG-NK4FG-7XKXM-BD4WF-3C624
SharePoint Workspace (Groove) 2013H7R7V-WPNXQ-WCYYC-76BGV-VT7GH
SharePoint Designer (Frontpage) 2013 Retail [Preview]?????-?????-?????-?????-?????
SharePoint Designer (Frontpage) 2013 RetailGYJRG-NMYMF-VGBM4-T3QD4-842DW
+ +### _Office 2010_ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Professional Plus 2010VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB
Standard 2010V7QKV-4XVVR-XYV4D-F7DFM-8R6BM
Project Professional 2010YGX6F-PGV49-PGW3J-9BTGG-VHKC6
Project Standard 20104HP3K-88W3F-W2K3D-6677X-F9PGB
Visio Professional 20107MCW8-VRQVK-G677T-PDJCM-Q8TCP
Visio Standard 2010767HD-QGMWX-8QTDB-9G3R2-KHFGJ
Visio Premium 2010D9DWC-HPYVV-JGF4P-BTWQB-WX8BJ
Access 2010V7Y44-9T38C-R2VJK-666HK-T7DDX
Excel 2010H62QG-HXVKF-PP4HP-66KMR-CW9BM
OneNote 2010Q4Y4M-RHWJM-PY37F-MTKWH-D3XHX
Outlook 20107YDC2-CWM8M-RRTJC-8MDVC-X3DWQ
PowerPoint 2010RC8FX-88JRY-3PF7C-X8P67-P4VTT
Publisher 2010BFK7F-9MYHM-V68C7-DRQ66-83YTP
InfoPath 2010K96W8-67RPQ-62T9Y-J8FQJ-BT37T
SharePoint Workspace (Groove) 2010QYYW6-QP4CB-MBV6G-HYMCJ-4T3J4
Word 2010HVHB3-C6FV7-KQX9W-YQG79-CRY7T
Small Business Basics 2010D6QFG-VBYP2-XQHM7-J97RH-VVRCK
Starter 2010 RetailVXHHB-W7HBD-7M342-RJ7P8-CHBD6
SharePoint Designer (Frontpage) 2010 RetailH48K6-FB4Y6-P83GH-9J7XG-HDKKX
Office Mondo 1 2010YBJTT-JG6MD-V9Q7P-DBKXJ-38W9R
Office Mondo 2 20107TC2V-WXF6P-TD7RT-BQRXR-B8K32
\ No newline at end of file diff --git a/wiki/Windows-GVLK-Keys.md b/wiki/Windows-GVLK-Keys.md new file mode 100644 index 0000000..6af4228 --- /dev/null +++ b/wiki/Windows-GVLK-Keys.md @@ -0,0 +1,338 @@ +### _Windows Server 2019_ + + + + + + + + + + + + + + + +
ProductGVLK
Windows Server 2019 DatacenterWMDGN-G9PQG-XVVXX-R3X43-63DFG
Windows Server 2019 StandardN69G4-B89J2-4G8F4-WWYCC-J464C
Windows Server 2019 EssentialsWVDHN-86M7X-466P6-VHXV7-YY726
Windows Server 2019 Azure CoreFDNH6-VW9RW-BXPJ7-4XTYG-239TB
Windows Server 2019 Datacenter Semi-Annual Channel (v.1809)6NMRW-2C8FM-D24W7-TQWMY-CWH2D
Windows Server 2019 Standard Semi-Annual Channel (v.1809)N2KJX-J94YW-TQVFB-DG9YT-724CC
Windows Server 2019 ARM64GRFBW-QNDC4-6QBHG-CCK3B-2PR88
+ +### _Windows Server 2016_ + + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows Server 2016 Standard Semi-Annual Channel (v.1803)PTXN8-JFHJM-4WC78-MPCBR-9W4KR
Windows Server 2016 Datacenter Semi-Annual Channel (v.1803)2HXDN-KRXHB-GPYC7-YCKFJ-7FVDG
Windows Server 2016 Datacenter Semi-Annual Channel (v.1709)6Y6KB-N82V8-D8CQV-23MJW-BWTG6
Windows Server 2016 Standard Semi-Annual Channel (v.1709)DPCNP-XQFKJ-BJF7R-FRC8D-GF6G4
Windows Server 2016 ARM64K9FYF-G6NCK-73M32-XMVPY-F9DRR
Windows Server 2016 DatacenterCB7KF-BWN84-R7R2Y-793K2-8XDDG
Windows Server 2016 StandardWC2BQ-8NRM3-FDDYY-2BFGV-KHKQY
Windows Server 2016 EssentialsJCKRF-N37P4-C2D82-9YXRT-4M63B
Windows Server 2016 Cloud StorageQN4C6-GBJD2-FB422-GHWJK-GJG2R
Windows Server 2016 Azure CoreVP34G-4NPPG-79JTQ-864T4-R3MQX
WNCYY-GFBH2-M4WTT-XQ2FP-PG2K9
+ +### _Windows 10_ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows 10 Professional WorkstationNRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J
Windows 10 Professional Workstation N9FNHH-K3HBT-3W4TD-6383H-6XYWF
Windows 10 Enterprise GYYVX9-NTFWV-6MDM3-9PT4T-4M68B
Windows 10 Enterprise G N44RPN-FTY23-9VTTB-MP9BX-T84FV
Windows 10 Enterprise LTSC 2019M7XTQ-FN8P6-TTKYV-9D4CC-J462D
Windows 10 Enterprise LTSC 2019 N92NFX-8DJQP-P6BBQ-THF9C-7CG2H
Windows 10 Remote Server7NBT4-WGBQX-MP4H7-QXFF8-YP3KX
Windows 10 Enterprise for Remote SessionsCPWHC-NT2C7-VYW78-DHDB2-PG3GK
Windows 10 S (Lean)NBTWJ-3DR69-3C4V8-C26MC-GQ9M6
Windows 10 ProfessionalW269N-WFGWX-YVC9B-4J6C9-T83GX
Windows 10 Professional NMH37W-N47XK-V7XM9-C7227-GCQG9
HMNWJ-V69R6-B2CDC-8P7VT-2373K
Windows 10 Professional Education6TP4R-GNPTD-KYYHQ-7B7DP-J447Y
Windows 10 Professional Education NYVWGF-BXNMC-HTQYQ-CPQ99-66QFC
Windows 10 EducationNW6C2-QMPVW-D7KKK-3GKT6-VCFB2
F48BJ-8NX82-MRVY9-PF8BW-HMHY2
Windows 10 Education N2WH4N-8QGBV-H22JP-CT43Q-MDWWJ
PPWGW-8NW9C-J77Q9-8WHB9-QV64W
Windows 10 EnterpriseNPPR9-FWDCX-D2C8J-H872K-2YT43
96YNV-9X4RP-2YYKB-RMQH4-6Q72D
TN6CM-KCVXP-VVP8X-YVCF7-R9BDH
3PMKQ-YNVGT-HFJGG-2F4FQ-9D6T7
Windows 10 Enterprise NDPH2V-TTNVB-4X9Q3-TJR4H-KHJW4
WGGHN-J84D6-QYCPR-T7PJ7-X766F
Windows 10 Enterprise SH76BG-QBNM7-73XY9-V6W2T-684BJ
Windows 10 Enterprise S NX4R4B-NV6WD-PKTVK-F98BH-4C2J8
Windows 10 Enterprise 2015 LTSBWNMTR-4C88C-JK8YV-HQ7T2-76DF9
Windows 10 Enterprise 2015 LTSB N2F77B-TNFGY-69QQF-B8YKP-D69TJ
RW7WN-FMT44-KRGBK-G44WK-QV7YK
Windows 10 Enterprise 2016 LTSBDCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ
Windows 10 Enterprise 2016 LTSB NQFFDN-GRT3P-VKWWX-X7T3R-8B639
Windows 10 Home
Windows 10 Core
TX9XD-98N7V-6WMQ6-BX7FG-H8Q99
33QT6-RCNYF-DXB4F-DGP7B-7MHX9
Windows 10 Home N
Windows 10 Core N
3KHY7-WNT83-DGQKR-F7HPR-844BM
CP4KF-NG6TC-9K6QF-P6GTT-H8RBM
Windows 10 Home Single Language
Windows 10 Core Single Language
7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
9HGRW-NH2CQ-XQHJD-YCRWB-6VJV7
4NX46-6DHCG-MR3PH-9FMCX-3RQ3G
Windows 10 Home Country Specific
Windows 10 Core Country Specific
PVMJN-6DFY6-9CCP6-7BKTT-D3WVR
JN9HR-MH7K4-DBPDD-TFTXF-Q9MMF
+ +### _Windows Server 2012 R2_ + + + + + + + + + + + + +
ProductGVLK
Windows Server 2012 R2 StandardD2N9P-3P6X9-2R39C-7RTCD-MDVJX
Windows Server 2012 R2 DatacenterW3GGN-FT8W3-Y4M27-J84CP-Q3VJ9
Windows Server 2012 R2 EssentialsKNC87-3J2TX-XB4WP-VCPJV-M4FWM
Windows Server 2012 R2 Cloud Storage3NPTF-33KPT-GGBPR-YX76B-39KDD
+ +### _Windows 8.1_ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows 8.1 ProfessionalGCRJD-8NW9H-F2CDX-CCM8D-9D6T9
Windows 8.1 Professional NHMCNV-VVBFX-7HMBH-CTY9B-B4FXY
Windows 8.1 Professional WMC789NJ-TQK6T-6XTH8-J39CJ-J8D3P
Windows 8.1 EnterpriseMHF9N-XY6XB-WVXMC-BTDCT-MKKG7
FHQNR-XYXYC-8PMHT-TV4PH-DRQ3H
Windows 8.1 Enterprise NTT4HM-HN7YT-62K67-RGRQJ-JFFXW
NDRDJ-3YBP2-8WTKD-CK7VB-HT8KW
Windows 8.1 Embedded Industry AutomotiveVHXM3-NR6FT-RY6RT-CK882-KW2CJ
Windows 8.1 Embedded Industry EnterpriseFNFKF-PWTVT-9RC8H-32HB2-JB34X
Windows 8.1 Embedded Industry ProfessionalNMMPB-38DD4-R2823-62W8D-VXKJB
Windows 8.1 CoreM9Q9P-WNJJT-6PXPY-DWX8H-6XWKK
Windows 8.1 Core N7B9N3-D94CG-YTVHR-QBPX3-RJP64
Windows 8.1 Core Single LanguageBB6NG-PQ82V-VRDPW-8XVD2-V8P66
Windows 8.1 Core Country SpecificNCTT7-2RGK8-WMHRF-RY7YQ-JTXG3
Windows 8.1 Core ARMXYTND-K6QKT-K2MRH-66RTM-43JKP
Windows 8.1 Core Connected3PY8R-QHNP9-W7XQD-G6DPH-3J2C9
Windows 8.1 Core Connected NQ6HTR-N24GM-PMJFP-69CD8-2GXKR
Windows 8.1 Core Connected Country SpecificR962J-37N87-9VVK2-WJ74P-XTMHR
Windows 8.1 Core Connected Single LanguageKF37N-VDV38-GRRTV-XH8X6-6F3BB
Windows 8.1 Professional StudentMX3RK-9HNGX-K3QKC-6PJ3F-W8D7B
Windows 8.1 Professional Student NTNFGH-2R6PB-8XM3K-QYHX2-J4296
+ +### _Windows Server 2012_ + + + + + + + + + + + + + + + + +
ProductGVLK
Windows Server 2012
Windows 8 Core
BN3D2-R7TKB-3YPBD-8DRP2-27GG4
Windows Server 2012 N
Windows 8 Core N
8N2M2-HWPGY-7PGT9-HGDD8-GVGGY
Windows Server 2012 Single Language
Windows 8 Core Single Language
2WN2H-YGCQR-KFX6K-CD6TF-84YXQ
Windows Server 2012 Country Specific
Windows 8 Core Country Specific
4K36P-JN4VD-GDC6V-KDT89-DYFKP
Windows Server 2012 StandardXC9B7-NBPP2-83J2H-RHMBY-92BT4
Windows Server 2012 MultiPoint StandardHM7DN-YVMH3-46JC3-XYTG7-CYQJJ
Windows Server 2012 MultiPoint PremiumXNH6W-2V9GX-RGJ4K-Y8X6F-QGJ2G
Windows Server 2012 Datacenter48HP8-DN98B-MYWDG-T2DCC-8W83P
+ +### _Windows 8_ + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows 8 ProfessionalNG4HW-VH26C-733KW-K6F98-J8CK4
Windows 8 Professional NXCVCF-2NXM9-723PB-MHCB7-2RYQQ
Windows 8 Professional WMCGNBB8-YVD74-QJHX6-27H4K-8QHDG
NQ3PX-BBY8Y-RRHMM-TBHFW-PJ866
Windows 8 Enterprise32JNW-9KQ84-P47T8-D8GGY-CWCK7
8M9BN-YB7W9-YV3VJ-7WMGG-MKH3V
Windows 8 Enterprise NJMNMF-RHW7P-DMY6X-RF3DR-X2BQT
NCVKH-RB9D4-R86X8-GB8WG-4M2K6
Windows 8 Embedded Industry ProfessionalJVPDN-TBWJW-PD94V-QYKJ2-KWYQM
RYXVT-BNQG7-VD29F-DBMRY-HT73M
Windows 8 Embedded Industry EnterpriseNKB3R-R2F8T-3XCDP-7Q2KW-XWYQ2
Windows 8 Core
Windows Server 2012
BN3D2-R7TKB-3YPBD-8DRP2-27GG4
Windows 8 Core N
Windows Server 2012 N
8N2M2-HWPGY-7PGT9-HGDD8-GVGGY
Windows 8 Core Single Language
Windows Server 2012 Single Language
2WN2H-YGCQR-KFX6K-CD6TF-84YXQ
Windows 8 Core Country Specific
Windows Server 2012 Country Specific
4K36P-JN4VD-GDC6V-KDT89-DYFKP
Windows 8 Core ARMDXHJF-N9KQX-MFPVR-GHGQK-Y7RKV
+ +### _Windows Server 2008 R2_ + + + + + + + + + + + + + + + +
ProductGVLK
Windows MultiPoint Server 2010736RG-XDKJK-V34PF-BHK87-J6X3K
Windows Server 2008 R2 Web6TPJF-RBVHG-WBW2R-86QPH-6RTM4
Windows Server 2008 R2 HPC editionTT8MH-CG224-D3D7Q-498W2-9QCTX
Windows Server 2008 R2 StandardYC6KT-GKW9T-YTKYR-T4X34-R7VHC
Windows Server 2008 R2 Enterprise489J6-VHDMP-X63PK-3K798-CPX3Y
Windows Server 2008 R2 Datacenter74YFP-3QFB3-KQT8W-PMXWJ-7M648
Windows Server 2008 R2 for Itanium-based SystemsGT63C-RJFQ3-4GMB6-BRFB9-CB83V
+ +### _Windows 7_ + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows 7 ProfessionalFJ82H-XT6CR-J8D7P-XQJJ2-GPDD4
MYKDJ-XV4CV-M2D3P-KDVY4-MPTW8
Windows 7 Professional NMRPKT-YTG23-K7D7T-X2JMM-QY7MG
Windows 7 Professional EW82YF-2Q76Y-63HXB-FGJG9-GF7QX
Windows 7 Enterprise33PXH-7Y6KF-2VJC9-XBBR8-HVTHH
Windows 7 Enterprise NYDRBP-3D83W-TY26F-D46B2-XCKRJ
Windows 7 Enterprise EC29WB-22CC8-VJ326-GHFJW-H9DH4
Windows 7 Embedded POSReadyYBYF6-BHCR3-JPKRB-CDW7B-F9BK4
Windows 7 Embedded ThinPC73KQT-CD9G6-K7TQG-66MRP-CQ22C
Windows 7 Embedded StandardXGY72-BRBBT-FF8MH-2GG8H-W7KCW
+ +### _Windows Server 2008_ + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows Server 2008 WebWYR28-R7TFJ-3X2YQ-YCY4H-M249D
Windows Server 2008 StandardTM24T-X9RMF-VWXK6-X8JC9-BFGM2
Windows Server 2008 Standard without Hyper-VW7VD6-7JFBR-RX26B-YKQ3Y-6FFFJ
Windows Server 2008 EnterpriseYQGMW-MPWTJ-34KDK-48M3W-X4Q6V
Windows Server 2008 Enterprise without Hyper-V39BXF-X8Q23-P2WWT-38T2F-G3FPG
Windows Server 2008 HPC edition (Computer Cluster)RCTX3-KWVHP-BR6TB-RB6DM-6X7HP
Windows Server 2008 Datacenter7M67G-PC374-GR742-YH8V4-TCBY3
Windows Server 2008 Datacenter without Hyper-V22XQ2-VRXRG-P8D42-K34TD-G3QQC
Windows Server 2008 for Itanium-Based Systems4DWFP-JF3DJ-B7DTH-78FJB-PDRHK
+ +### _Windows Vista_ + + + + + + + + + + + + +
ProductGVLK
Windows Vista BusinessYFKBB-PQJJV-G996G-VWGXY-2V3X8
Windows Vista Business NHMBQG-8H2RH-C77VX-27R82-VMQBT
Windows Vista EnterpriseVKK3X-68KWM-X2YGT-QR4M6-4BWMV
Windows Vista Enterprise NVTC42-BM838-43QHV-84HX6-XJXKV
+ +### _Windows Previews_ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductGVLK
Windows Server 2019 Datacenter [Preview]6XBNX-4JQGW-QX6QG-74P76-72V67
Windows Server 2019 Standard [Preview]MFY9F-XBN2F-TYFMP-CCV49-RMYVH
Windows 10 Home / Core [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Home / Core Country Specific [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Home / Core N [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Home / Core Single Language [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Home / Core [Technical Preview]?????-?????-?????-?????-?????
Windows 10 Education [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Education N [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Enterprise [Preview]QNMXX-GCD3W-TCCT4-872RV-G6P4J
Windows 10 Enterprise 2015 LTSB [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Enterprise 2015 LTSB N [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Enterprise N [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Professional N [Pre-Release]?????-?????-?????-?????-?????
Windows 10 Professional [Preview]XQHPH-N4D9W-M8P96-DPDFP-TMVPY
Windows 10 Professional WMC [Pre-Release]NKPM6-TCVPT-3HRFX-Q4H9B-QJ34Y
328NF-RTPQT-84J4Q-V44B8-78R2B
Windows 10 IoT Core [Pre-Release]7NX88-X6YM3-9Q3YT-CCGBF-KBVQF
NHY4C-KCMKV-V9K9M-7R43T-KTP64
Windows 10 Core Connected [Pre-Release]DJMYQ-WN6HG-YJ2YX-82JDB-CWFCW
QBWKP-NFVG3-CYGTT-724CF-FCYPW
Windows 10 Core Connected N [Pre-Release]JQNT7-W63G4-WX4QX-RD9M9-6CPKM
TKDDW-N77V2-WXKMG-QY6WQ-WQJXM
Windows 10 Core Connected Single Language [Pre-Release]QQMNF-GPVQ6-BFXGG-GWRCX-7XKT7
RQ2MN-RKR94-P86YQ-TM76X-P3667
Windows 10 Core Connected Country Specific [Pre-Release]FTNXM-J4RGP-MYQCV-RVM8R-TVH24
TNPJK-GCKPR-4WX4C-HCJHT-HFRC4
Windows 10 Professional S [Pre-Release]3NF4D-GF9GY-63VKH-QRC3V-7QW8P
NFDD9-FX3VM-DYCKP-B8HT8-D9M2C
Windows 10 Professional S N [Pre-Release]KNDJ3-GVHWT-3TV4V-36K8Y-PR4PF
8Q36Y-N2F39-HRMHT-4XW33-TCQR4
Windows 10 Professional Student [Pre-Release]YNXW3-HV3VB-Y83VG-KPBXM-6VH3Q
N6X24-448X6-HYV8Y-8XQ3V-DRRDQ
Windows 10 Professional Student N [Pre-Release]8G9XJ-GN6PJ-GW787-MVV7G-GMR99
XHGFB-WNK7Q-BG8VG-BG2KQ-KKWX9
Windows 10 PPIPro [Pre-Release (build 15063)]?????-?????-?????-?????-?????
Windows 8 Core / Server 2012 [RC]?????-?????-?????-?????-?????
Windows 8 Core / Server 2012 Country Specific [RC]?????-?????-?????-?????-?????
Windows 8 Core / Server 2012 N [RC]?????-?????-?????-?????-?????
Windows 8 Core / Server 2012 Single Language [RC]?????-?????-?????-?????-?????
Windows 8 Core ARM64 [RC]?????-?????-?????-?????-?????
Windows 8 Embedded Industry Professional [Beta]?????-?????-?????-?????-?????
Windows 8 Embedded Industry Enterprise [Beta]?????-?????-?????-?????-?????
Windows 8.1 Enterprise [Preview]2MP7K-98NK8-WPVF3-Q2WDG-VMD98
Windows 8.1 Professional (Blue) [Preview]MTWNQ-CKDHJ-3HXW9-Q2PFX-WB2HQ
Windows 8 Professional WMC [RC]MY4N9-TGH34-4X4VY-8FG2T-RRDPV
Windows 8.x [Preview]MPWP3-DXNP9-BRD79-W8WFP-3YFJ6
Windows 8.x ARM64 [Preview]?????-?????-?????-?????-?????
Windows Next Core Connected [Pre-Release]?????-?????-?????-?????-?????
Windows Next Core Connected N [Pre-Release]?????-?????-?????-?????-?????
Windows Next Core Connected Country Specific [Pre-Release]?????-?????-?????-?????-?????
Windows Next Core Connected Single Language [Pre-Release]?????-?????-?????-?????-?????
Windows Next Professional Student [Pre-Release]?????-?????-?????-?????-?????
Windows Next Professional Student N [Pre-Release]?????-?????-?????-?????-?????
Windows Next Embedded Industry Professional [Beta]XY4TQ-CXNVJ-YCT73-HH6R7-R897X
Windows Next Embedded Industry Enterprise [Beta]XCNC9-BPK3C-KCCMD-FTDTC-KWY4G
WN3XP-M9YFD-JRJ84-4J9FB-QJY4G
Windows Next Embedded Industry Automotive [Beta]GN2X2-KXTK6-P92FR-VBB9G-PDJFP
434XB-NH62H-JG7RG-P3KMD-XHHJC
Windows Server Next MultiPoint Standard [Preview]?????-?????-?????-?????-?????
Windows Server Next MultiPoint Premium [Preview]?????-?????-?????-?????-?????
Windows Server Next Enterprise [Preview]?????-?????-?????-?????-?????
Windows Server Next Standard [Preview]?????-?????-?????-?????-?????
Windows Server Next Web [Preview]?????-?????-?????-?????-?????
Windows Server Next HPC Edition [Preview]?????-?????-?????-?????-?????
Windows Server Next HI [Preview]7VX4N-3VDHQ-VYGHB-JXJVP-9QB26
Enterprise ProdKey3 Win 9984 DLA/Bypass NQR Test?????-?????-?????-?????-?????
Windows Server 2012 R2 Essentials [Preview]?????-?????-?????-?????-?????
Windows Server 2016 Datacenter [Preview]VRDD2-NVGDP-K7QG8-69BR4-TVFHB
Windows Vista Business [Preview 1]XQYF4-QVCMY-YXQRD-9QPV8-3YP9V
Windows Vista Business [Preview 2]YVT36-YVCP2-J97GQ-7T22R-RWV8P
Windows Vista Business N [Preview]HGBJ9-RWD6M-6HDGW-6T2XD-JQ66F
Windows Vista Enterprise [Preview 1]3JHG3-Y66GP-B7F3K-JFVX2-VBH7K
Windows Vista Enterprise [Beta-2 build 5384]MF9PG-RQK7R-26BPJ-TWFYK-RHXCM
Windows Vista Enterprise N [Preview]?????-?????-?????-?????-?????
Windows Longhorn Web [Preview]MDRCM-4WKCW-J93FF-J9Q48-M6KBB
Windows Longhorn HPC Edition [Preview]?????-?????-?????-?????-?????
Windows Longhorn Standard [Preview]Q37JX-P3HHB-GKRH2-PDBKG-GGXPW
Windows Longhorn Enterprise [Preview]7KYMQ-R788Q-4RF69-KTWKM-92PFJ
Windows Longhorn Datacenter [Preview]HR8VD-7DHG2-48378-M9D73-28F4T
Windows Longhorn for Itanium Systems [Preview]CWV9H-PHGPW-V93WV-QBQV9-8V336
Windows 7 Business [Preview]?????-?????-?????-?????-?????
Windows 7 Business N [Preview]?????-?????-?????-?????-?????
Windows 7 Enterprise [Preview]?????-?????-?????-?????-?????
Windows 7 Enterprise N [Preview]?????-?????-?????-?????-?????
Windows 7 Server Web [Preview]?????-?????-?????-?????-?????
Windows 7 Server Standard [Preview]?????-?????-?????-?????-?????
Windows 7 Server Standard without Hyper-V [Preview]?????-?????-?????-?????-?????
Windows 7 Server Enterprise [Preview]?????-?????-?????-?????-?????
Windows 7 Server Enterprise without Hyper-V [Preview]?????-?????-?????-?????-?????
Windows 7 Server Datacenter [Preview]?????-?????-?????-?????-?????
Windows 7 Server Datacenter without Hyper-V [Preview]?????-?????-?????-?????-?????
Windows 7 Server for Itanium Systems [Preview]?????-?????-?????-?????-?????
Windows Next Education [Pre-Release]?????-?????-?????-?????-?????
Windows Next Education N [Pre-Release]?????-?????-?????-?????-?????
Windows Next Professional [Pre-Release]?????-?????-?????-?????-?????
Windows Next Professional N [Pre-Release]?????-?????-?????-?????-?????
Windows Next Enterprise N [Pre-Release]?????-?????-?????-?????-?????
Windows Next Enterprise [Pre-Release]?????-?????-?????-?????-?????
Windows Next Enterprise S [Pre-Release]?????-?????-?????-?????-?????
Windows Next Enterprise S N [Pre-Release]?????-?????-?????-?????-?????
Windows Next Professional S [Pre-Release]?????-?????-?????-?????-?????
Windows Next Professional S N [Pre-Release]?????-?????-?????-?????-?????
\ No newline at end of file