clean-up: fix PEP8 E402 module level import not at top of file
--- a/BeremizIDE.py Mon Aug 21 21:55:18 2017 +0300
+++ b/BeremizIDE.py Mon Aug 21 22:41:37 2017 +0300
@@ -32,16 +32,8 @@
-import util.paths as paths
from types import ListType
-beremiz_dir = paths.AbsDir(__file__)
- return os.path.join(beremiz_dir, *args)
@@ -53,7 +45,11 @@
+from threading import Lock, Timer, currentThread +from time import time as gettime +import util.paths as paths from docutil import OpenHtmlFrame
from editors.EditorPanel import EditorPanel
from editors.Viewer import Viewer
@@ -67,12 +63,47 @@
from controls import EnhancedStatusBar as esb
from dialogs.AboutDialog import ShowAboutDialog
-from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE
+from PLCControler import \ from ProjectController import ProjectController, GetAddMenuItems, MATIEC_ERROR_MODEL, ITEM_CONFNODE
+ POUINSTANCEVARIABLESPANEL,\ + EncodeFileSystemPath, \ +from util.BitmapLibrary import GetBitmap +beremiz_dir = paths.AbsDir(__file__) + return os.path.join(beremiz_dir, *args) if wx.Platform == '__WXMSW__':
@@ -84,10 +115,9 @@
-from threading import Lock, Timer, currentThread
MainThread = currentThread().ident
-from time import time as gettime
@@ -203,20 +233,6 @@
ID_FILEMENURECENTPROJECTS = wx.NewId()
-from IDEFrame import TITLE,\
- POUINSTANCEVARIABLESPANEL,\
- EncodeFileSystemPath, DecodeFileSystemPath
-from util.BitmapLibrary import GetBitmap
@@ -1095,8 +1111,6 @@
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
Max_Traceback_List_Size = 20
--- a/Beremiz_service.py Mon Aug 21 21:55:18 2017 +0300
+++ b/Beremiz_service.py Mon Aug 21 22:41:37 2017 +0300
@@ -26,7 +26,14 @@
from threading import Thread
+import Pyro.core as pyro +from runtime import PLCObject, PLCprint, ServicePublisher +import util.paths as paths @@ -101,7 +108,7 @@
-import util.paths as paths
beremiz_dir = paths.AbsDir(__file__)
@@ -114,7 +121,6 @@
if __name__ == '__main__':
__builtin__.__dict__['_'] = lambda x: x
@@ -375,8 +381,6 @@
currenticon = self.MakeIcon(defaulticon)
self.SetIcon(currenticon, "Beremiz Service")
-from runtime import PLCObject, PLCprint, ServicePublisher
-import Pyro.core as pyro
if not os.path.isdir(WorkingDir):
@@ -531,8 +535,6 @@
--- a/IDEFrame.py Mon Aug 21 21:55:18 2017 +0300
+++ b/IDEFrame.py Mon Aug 21 22:41:37 2017 +0300
@@ -26,6 +26,7 @@
from types import TupleType
@@ -194,8 +195,6 @@
# -------------------------------------------------------------------------------
def EncodeFileSystemPath(path, use_base64=True):
path = path.encode(sys.getfilesystemencoding())
--- a/PLCOpenEditor.py Mon Aug 21 21:55:18 2017 +0300
+++ b/PLCOpenEditor.py Mon Aug 21 22:41:37 2017 +0300
@@ -33,6 +33,26 @@
import util.paths as paths
+from IDEFrame import IDEFrame, AppendMenu + POUINSTANCEVARIABLESPANEL, \ +from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath +from editors.Viewer import Viewer +from PLCControler import PLCControler +from dialogs import ProjectDialog +from dialogs.AboutDialog import ShowAboutDialog beremiz_dir = paths.AbsDir(__file__)
__version__ = "$Revision: 1.130 $"
@@ -76,14 +96,6 @@
from util.misc import InstallLocalRessources
InstallLocalRessources(beremiz_dir)
-from IDEFrame import IDEFrame, AppendMenu
-from IDEFrame import TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, PAGETITLES
-from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
-from editors.Viewer import Viewer
-from PLCControler import PLCControler
-from dialogs import ProjectDialog
-from dialogs.AboutDialog import ShowAboutDialog
# -------------------------------------------------------------------------------
# PLCOpenEditor Main Class
--- a/canfestival/canfestival.py Mon Aug 21 21:55:18 2017 +0300
+++ b/canfestival/canfestival.py Mon Aug 21 22:41:37 2017 +0300
@@ -26,35 +26,46 @@
+from gnosis.xml.pickle import * +from gnosis.xml.pickle.util import setParanoia import util.paths as paths
+from util.TranslationCatalogs import AddCatalog +from ConfigTreeNode import ConfigTreeNode +from PLCControler import \ -base_folder = paths.AbsParentDir(__file__, 2)
-CanFestivalPath = os.path.join(base_folder, "CanFestival-3")
-sys.path.append(os.path.join(CanFestivalPath, "objdictgen"))
+ from nodelist import NodeList + base_folder = paths.AbsParentDir(__file__, 2) + CanFestivalPath = os.path.join(base_folder, "CanFestival-3") + sys.path.append(os.path.join(CanFestivalPath, "objdictgen"))
+ from nodelist import NodeList -from nodelist import NodeList
from nodemanager import NodeManager
import canfestival_config as local_canfestival_config
-from ConfigTreeNode import ConfigTreeNode
from commondialogs import CreateNodeDialog
from subindextable import IECTypeConversion, SizeConversion
-from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
from SlaveEditor import SlaveEditor, MasterViewer
from NetworkEditor import NetworkEditor
-from gnosis.xml.pickle import *
-from gnosis.xml.pickle.util import setParanoia
+AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale")) -from util.TranslationCatalogs import AddCatalog
-AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale"))
# --------------------------------------------------
--- a/connectors/PYRO/__init__.py Mon Aug 21 21:55:18 2017 +0300
+++ b/connectors/PYRO/__init__.py Mon Aug 21 22:41:37 2017 +0300
@@ -30,8 +30,9 @@
service_type = '_PYRO._tcp.local.'
# this module attribute contains a list of DNS-SD (Zeroconf) service types
# supported by this connector confnode.
--- a/controls/DebugVariablePanel/DebugVariablePanel.py Mon Aug 21 21:55:18 2017 +0300
+++ b/controls/DebugVariablePanel/DebugVariablePanel.py Mon Aug 21 22:41:37 2017 +0300
@@ -30,10 +30,11 @@
+matplotlib.use('WX') # noqa from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
from editors.DebugViewer import DebugViewer
from util.BitmapLibrary import GetBitmap
@@ -41,6 +42,7 @@
from DebugVariableTextViewer import DebugVariableTextViewer
from DebugVariableGraphicViewer import *
MILLISECOND = 1000000 # Number of nanosecond in a millisecond
SECOND = 1000 * MILLISECOND # Number of nanosecond in a second
MINUTE = 60 * SECOND # Number of nanosecond in a minute
--- a/controls/PouInstanceVariablesPanel.py Mon Aug 21 21:55:18 2017 +0300
+++ b/controls/PouInstanceVariablesPanel.py Mon Aug 21 22:41:37 2017 +0300
@@ -28,6 +28,17 @@
import wx.lib.agw.customtreectrl as CT
+from PLCControler import \ +from util.BitmapLibrary import GetBitmap # Customize CustomTreeItem for adding icon on item right
CT.GenericTreeItem._rightimages = []
@@ -116,9 +127,6 @@
_ButtonCallbacks = namedtuple("ButtonCallbacks", ["leftdown", "dclick"])
-from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION
-from util.BitmapLibrary import GetBitmap
class PouInstanceVariablesPanel(wx.Panel):
--- a/runtime/PLCObject.py Mon Aug 21 21:55:18 2017 +0300
+++ b/runtime/PLCObject.py Mon Aug 21 22:41:37 2017 +0300
@@ -28,6 +28,7 @@
from targets.typemapping import LogLevelsDefault, LogLevelsCount, TypeTranslator, UnpackDebugBuffer
@@ -38,8 +39,6 @@
from _ctypes import dlopen, dlclose
def get_last_traceback(tb):
--- a/svgui/pyjs/build.py Mon Aug 21 21:55:18 2017 +0300
+++ b/svgui/pyjs/build.py Mon Aug 21 22:41:37 2017 +0300
@@ -7,6 +7,7 @@
from os.path import join, dirname, basename, abspath, split, isfile, isdir
from optparse import OptionParser
from cStringIO import StringIO
@@ -542,9 +543,6 @@
def add_subdeps(deps, mod_name):
--- a/svgui/pyjs/jsonrpc/django/jsonrpc.py Mon Aug 21 21:55:18 2017 +0300
+++ b/svgui/pyjs/jsonrpc/django/jsonrpc.py Mon Aug 21 22:41:37 2017 +0300
@@ -1,9 +1,15 @@
# original code: http://trac.pyworks.org/pyjamas/wiki/DjangoWithPyJamas
# also from: http://www.pimentech.fr/technologies/outils
+from datetime import date from django.utils import simplejson
from django.http import HttpResponse
+from django import forms +from django.core.serializers import serialize from pyjs.jsonrpc import JSONRPCServiceBase
# JSONRPCService and jsonremote are used in combination to drastically
@@ -64,8 +70,6 @@
# (r'^formsservice/$', 'djangoapp.views.processor'),
-from django import forms
@@ -208,11 +212,6 @@
# (r'^service1/$', 'djangoapp.views.jsonservice'),
-from django.core.serializers import serialize
-from datetime import date
def dict_datetimeflatten(item):
for k, v in item.items():
--- a/svgui/pyjs/lib/pyjslib.py Mon Aug 21 21:55:18 2017 +0300
+++ b/svgui/pyjs/lib/pyjslib.py Mon Aug 21 22:41:37 2017 +0300
@@ -231,7 +231,9 @@
+# as comment on line 20 says +# import sys should be below --- a/svgui/pyjs/pyjs.py Mon Aug 21 21:55:18 2017 +0300
+++ b/svgui/pyjs/pyjs.py Mon Aug 21 22:41:37 2017 +0300
@@ -20,6 +20,7 @@
# the standard location for builtins (e.g. pyjslib) can be
# over-ridden by changing this. it defaults to sys.prefix
@@ -1520,9 +1521,6 @@
raise TranslationError("unsupported type (in expr)", node)
def translate(file_name, module_name, debug=False):
--- a/targets/typemapping.py Mon Aug 21 21:55:18 2017 +0300
+++ b/targets/typemapping.py Mon Aug 21 22:41:37 2017 +0300
@@ -23,14 +23,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from datetime import timedelta as td ctypes.pythonapi.PyString_AsString.argtypes = (ctypes.c_void_p,)
ctypes.pythonapi.PyString_AsString.restype = ctypes.POINTER(ctypes.c_char)
-from datetime import timedelta as td
class IEC_STRING(Structure):
Must be changed according to changes in iec_types.h
--- a/util/Zeroconf.py Mon Aug 21 21:55:18 2017 +0300
+++ b/util/Zeroconf.py Mon Aug 21 22:41:37 2017 +0300
@@ -1,82 +1,78 @@
-""" Multicast DNS Service Discovery for Python, v0.12
- Copyright (C) 2003, Paul Scott-Murphy
- This module provides a framework for the use of DNS Service Discovery
- using IP multicast. It has been tested against the JRendezvous
- implementation from <a href="http://strangeberry.com">StrangeBerry</a>,
- and against the mDNSResponder from Mac OS X 10.3.8.
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+# Multicast DNS Service Discovery for Python, v0.12 +# Copyright (C) 2003, Paul Scott-Murphy +# This module provides a framework for the use of DNS Service Discovery +# using IP multicast. It has been tested against the JRendezvous +# implementation from <a href="http://strangeberry.com">StrangeBerry</a>, +# and against the mDNSResponder from Mac OS X 10.3.8. - You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""0.12 update - allow selection of binding interface
- typo fix - Thanks A. M. Kuchlingi
- removed all use of word 'Rendezvous' - this is an API change"""
+# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. -"""0.11 update - correction to comments for addListener method
- support for new record types seen from OS X
- ignore unknown DNS record types
- works alongside other processes using port 5353 (e.g. on Mac OS X)
- tested against Mac OS X 10.3.2's mDNSResponder
- corrections to removal of list entries for service browser"""
+# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. -"""0.10 update - Jonathon Paisley contributed these corrections:
- always multicast replies, even when query is unicast
- correct a pointer encoding problem
- can now write records in any order
- traceback shown on failure
- better TXT record parsing
- server is now separate from name
- can cancel a service browser
- modified some unit tests to accommodate these changes"""
-"""0.09 update - remove all records on service unregistration
- fix DOS security problem with readName"""
-"""0.08 update - changed licensing to LGPL"""
-"""0.07 update - faster shutdown on engine
- pointer encoding of outgoing names
- ServiceBrowser now works
-"""0.06 update - small improvements with unit tests
- added defined exception types
- fixed hostname/interface problem
- fixed socket timeout problem
- fixed addServiceListener() typo bug
- using select() for socket reads
- tested on Debian unstable with Python 2.2.2"""
-"""0.05 update - ensure case insensitivty on domain names
- support for unicast DNS queries"""
-"""0.04 update - added some unit tests
- added __ne__ adjuncts where required
- ensure names end in '.local.'
- timeout on receiving socket for clean shutdown"""
-__author__ = "Paul Scott-Murphy"
-__email__ = "paul at scott dash murphy dot com"
+# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# 0.12 update - allow selection of binding interface +# typo fix - Thanks A. M. Kuchlingi +# removed all use of word 'Rendezvous' - this is an API change +# 0.11 update - correction to comments for addListener method +# support for new record types seen from OS X +# ignore unknown DNS record types +# fixes to name decoding +# works alongside other processes using port 5353 (e.g. on Mac OS X) +# tested against Mac OS X 10.3.2's mDNSResponder +# corrections to removal of list entries for service browser +# 0.10 update - Jonathon Paisley contributed these corrections: +# always multicast replies, even when query is unicast +# correct a pointer encoding problem +# can now write records in any order +# traceback shown on failure +# better TXT record parsing +# server is now separate from name +# can cancel a service browser +# modified some unit tests to accommodate these changes +# 0.09 update - remove all records on service unregistration +# fix DOS security problem with readName +# 0.08 update - changed licensing to LGPL +# 0.07 update - faster shutdown on engine +# pointer encoding of outgoing names +# ServiceBrowser now works +# 0.06 update - small improvements with unit tests +# added defined exception types +# fixed hostname/interface problem +# fixed socket timeout problem +# fixed addServiceListener() typo bug +# using select() for socket reads +# tested on Debian unstable with Python 2.2.2 +# 0.05 update - ensure case insensitivty on domain names +# support for unicast DNS queries +# 0.04 update - added some unit tests +# added __ne__ adjuncts where required +# ensure names end in '.local.' +# timeout on receiving socket for clean shutdown @@ -86,6 +82,12 @@
+__author__ = "Paul Scott-Murphy" +__email__ = "paul at scott dash murphy dot com" __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]