Minor organization shifts

This commit is contained in:
karxi 2017-03-07 22:28:15 -05:00
parent dd683a3cf7
commit bf68bc5911
4 changed files with 74 additions and 60 deletions

View file

@ -1,3 +1,4 @@
# vim: set autoindent ts=4 sts=4 sw=4 textwidth=79 expandtab:
# -*- coding=UTF-8; tab-width: 4 -*-
from __future__ import print_function
@ -9,7 +10,11 @@ from os import remove
import dataobjs, generic, memos, parsetools, ostools
from version import _pcVersion
from pnc.dep.attrdict import AttrDict
try:
from pnc.attrdict import AttrDict
except ImportError:
# Fall back on the old location, just in case
from pnc.dep.attrdict import AttrDict
#~from styling import styler
_datadir = ostools.getDataDir()
@ -521,7 +526,3 @@ class ConsoleInput(QtGui.QLineEdit):
parent.text.area.keyPressEvent(event)
else:
super(ConsoleInput, self).keyPressEvent(event)
# vim: set autoindent ts=4 sts=4 sw=4 textwidth=79 expandtab:

View file

@ -15,7 +15,11 @@ from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin,
import parsetools
import pnc.lexercon as lexercon
from pnc.dep.attrdict import AttrDict
try:
from pnc.attrdict import AttrDict
except ImportError:
# Fall back on the old location - just in case
from pnc.dep.attrdict import AttrDict
class PesterTabWindow(QtGui.QFrame):
def __init__(self, mainwindow, parent=None, convo="convo"):

View file

@ -2,66 +2,23 @@
import os, shutil, sys, getopt
if os.path.dirname(sys.argv[0]):
os.chdir(os.path.dirname(sys.argv[0]))
import logging
logging.basicConfig(level=logging.WARNING)
import version
version.pcVerCalc()
import logging
version._py_version_check()
from datetime import *
import random
import re
from time import time
import threading, Queue
from pnc.dep.attrdict import AttrDict
logging.basicConfig(level=logging.WARNING)
def _py_version_check():
# == Python Version Checking ==
# Check that we're running the right version of Pesterchum.
# This is the version we need.
pyreq = {"major": 2, "minor": 7}
# Just some preprocessing to make formatting the version info a little
# easier. Note that the sys.version_info type doesn't convert to dict,
# despite having named indices like a namedtuple, so we have to do it
# manually.
# This is the version we have.
pyver = dict(zip(("major", "minor"), sys.version_info[:2]))
# Compose the base of an error message that we may use in the future.
errmsg = "ERROR: Pesterchum is designed to be run on Python \
{major}.{minor}.".format(**pyreq)
errmsg = [ errmsg ]
errmsg.append("It is not designed for use with Python {major}.{minor}.")
# Now we have a list that we can further process into a more specific
# error message.
if pyver["major"] > pyreq["major"]:
# We're using Python 3, which this script won't work with.
errmsg = errmsg.extend([
"Due to syntax differences,",
"it cannot be run with this version of Python."
])
errmsg = ' '.join(errmsg)
errmsg = errmsg.format(**pyver)
logging.critical(errmsg)
exit()
elif pyver["major"] != pyreq["major"] or pyver["minor"] < pyreq["minor"]:
# We're either not running Python 2 (we have something earlier?!) or
# we're below the minimum required minor version (e.g. 2.6 or 2.4 or
# similar).
# This means that we wouldn't have certain syntax improvements that we
# need - like inline generators, 'with' statements, lambdas, etc.
# NOTE: This MAY be lowered to 2.6 later, since there's little
# difference.
errmsg = errmsg.extend([
"This version of Python lacks certain features",
"that are necessary for it to run."
])
errmsg = ' '.join(errmsg)
errmsg = errmsg.format(**pyver)
logging.critical(errmsg)
exit()
# Actually do the version check.
_py_version_check()
try:
from pnc.attrdict import AttrDict
except ImportError:
# Fall back on the old location - just in case
logging.warning("Couldn't load attrdict from new loc; falling back")
from pnc.dep.attrdict import AttrDict
try:
import console

View file

@ -4,7 +4,11 @@ try:
except:
tarfile = None
import os, sys, shutil
from pnc.dep.attrdict import AttrDict
try:
from pnc.attrdict import AttrDict
except ImportError:
# Fall back on the old location - just in case
from pnc.dep.attrdict import AttrDict
logger = logging.getLogger(__name__)
@ -43,6 +47,54 @@ jsodeco = json.JSONDecoder()
# Whether or not we've completed an update (requires a restart).
has_updated = False
def _py_version_check():
import sys
# == Python Version Checking ==
# Check that we're running the right version of Python.
# This is the version we need.
pyreq = {"major": 2, "minor": 7}
# Just some preprocessing to make formatting the version info a little
# easier. Note that the sys.version_info type doesn't convert to dict,
# despite having named indices like a namedtuple, so we have to do it
# manually.
# This is the version we have.
pyver = dict(zip(("major", "minor"), sys.version_info[:2]))
# Compose the base of an error message that we may use in the future.
errmsg = "ERROR: Pesterchum is designed to be run on Python " + \
"{major}.{minor}.".format(**pyreq)
errmsg = [ errmsg ]
errmsg.append("It is not designed for use with Python {major}.{minor}.")
# Now we have a list that we can further process into a more specific
# error message.
if pyver["major"] > pyreq["major"]:
# We're using Python 3, which this script won't work with.
errmsg = errmsg.extend([
"Due to syntax differences,",
"it cannot be run with this version of Python."
])
errmsg = ' '.join(errmsg)
errmsg = errmsg.format(**pyver)
logger.critical(errmsg)
sys.exit()
elif pyver["major"] != pyreq["major"] or pyver["minor"] < pyreq["minor"]:
# We're either not running Python 2 (we have something earlier?!) or
# we're below the minimum required minor version (e.g. 2.6 or 2.4 or
# similar).
# This means that we wouldn't have certain syntax improvements that we
# need - like inline generators, 'with' statements, lambdas, etc.
# NOTE: This MAY be lowered to 2.6 later, since there's little
# difference.
errmsg = errmsg.extend([
"This version of Python lacks certain features",
"that are necessary for it to run."
])
errmsg = ' '.join(errmsg)
errmsg = errmsg.format(**pyver)
logger.critical(errmsg)
sys.exit()
# Not 100% finished - certain output formats seem odd
def get_pchum_ver(raw=0, pretty=False, file=None, use_hard_coded=None):
# If use_hard_coded is None, we don't care. If it's False, we won't use it.