Skip to content

Instantly share code, notes, and snippets.

View mudgen's full-sized avatar

Nick Mudge mudgen

View GitHub Profile
@mudgen
mudgen / Tree_View
Created July 29, 2013 23:36
Update Tree View component dataset without collapsing the tree. Expand Tree view Editable Tree
def updateTree(tree,data,paths=[]):
import itertools
from sets import Set
from javax.swing.tree import TreePath
jTree = tree.getViewport().getView()
root = TreePath(jTree.getModel().getRoot())
vectorPaths = jTree.getExpandedDescendants(root)
expandedPaths = Set(paths)
if vectorPaths != None:
for path in vectorPaths:
@mudgen
mudgen / icons_and_text_in_table_cell
Created July 30, 2013 00:06
Icons and text in same table cell
In table getDisplayTextAt function:
if col == 1:
return "Rev "+str(self.data.getValueAt(row,"Rev"))
return value
Add icon mapping to Image Path List in table customizer.
@mudgen
mudgen / invokeAsynchronous_with_args
Created August 12, 2013 20:17
Version of system.util.invokeAsynchronous() with arguments that get passed to the function.
def func(arg1,arg2):
print arg1,arg2
def invokeAsynchWithArgs(func,*args):
def asynchFunc(args=args,func=func):
func(*args)
system.util.invokeAsynchronous(asynchFunc)
invokeAsynchWithArgs(func, "cat","bat")
@mudgen
mudgen / dynamicloadclasses
Created September 9, 2013 17:22
Solution solving problems with loading classes dynamically or manually, solves classloader issues in client.
from org.python.core import imp
from java.lang import Thread
Thread.currentThread().setContextClassLoader(imp.getParentClassLoader())
import sys
from org.python.core import imp
from java.lang import Thread,Class
import xml.etree.ElementTree as ET
#Thread.currentThread().setContextClassLoader(imp.getParentClassLoader())
@mudgen
mudgen / binaryutil.py
Created September 24, 2013 15:38
Binary Utilities
global system,app
import system,app
def bytesEqual(bytes1,bytes2):
equal = True
for pair in zip(bytes1,bytes2):
if pair[0] != pair[1]:
return False
return True
@mudgen
mudgen / uniqulist
Created September 24, 2013 15:41
Unique List
def unique(items):
found = set()
keep = []
for item in items:
if item not in found:
found.add(item)
keep.append(item)
return keep
@mudgen
mudgen / EscapeSQL
Created October 9, 2013 18:42
escape arguments to SQL queries
# Key characters in this mappings dictionary will be
# replaced in escaped strings with their corresponding values.
#
# For example, if you had the mapping: 'B':'!B!' in the dictionary,
# then escape('Barb') would return the string: '!B!arb'
# (it is case sensitive)
#
# Add anything you like to the mappings dict
# This should work well for SQL-compliant databases
mappings = {"'":"''", "\\":"\\\\", "\n":"\\n", "\r":"\\r", "\t":"\\t"}
@mudgen
mudgen / designerlauncher
Created January 7, 2014 00:42
Custom Ignition designer launcher shell script.
java -cp launchclient.jar -Djavaws.sr.gateway.addr.0=server:port:sslport/main -Djavaws.sr.scope=D -Djavaws.sr.main=com.inductiveautomation.ignition.designer.DesignerStartupHook com.inductiveautomation.ignition.client.launch.BootstrapSwing
for a client:
java -cp launchclient.jar -Djavaws.sr.gateway.addr.0=ip address:8088:8043/main -Djavaws.sr.scope=C -Djavaws.sr.project=CustomerCare -Djavaws.sr.project.version=Published -Djavaws.sr.main=com.inductiveautomation.factorypmi.application.runtime.ClientLaunchHook com.inductiveautomation.ignition.client.launch.BootstrapSwing
download launchclient.jar from http://server:port/main/system/launchbin/launchclient.jar
@mudgen
mudgen / focusedinstancewindow
Created January 9, 2014 21:54
Choose an instance window to be focused in front
window.setSelected(True)
@mudgen
mudgen / projectlist
Created January 16, 2014 17:42
Ignition project list xml file: /main/system/projectlist
/main/system/projectlist