mirror of
https://github.com/ParticulateFlow/LPP.git
synced 2025-12-08 06:37:46 +00:00
increase python 2 - 3 compatibility
python 2 vs 3 imports
This commit is contained in:
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, os, subprocess, re, glob
|
import sys, os, re, glob
|
||||||
try:
|
try:
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, subprocess, re, glob, types
|
import sys, re, glob, types
|
||||||
import functools
|
import functools
|
||||||
from os import popen
|
from os import popen
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, subprocess, re, glob, types
|
import sys, re, glob, types
|
||||||
from os import popen
|
from os import popen
|
||||||
from math import * # any function could be used by set()
|
from math import * # any function could be used by set()
|
||||||
import os
|
import os
|
||||||
|
|||||||
@ -27,7 +27,7 @@ and dump match the format here - this will be checked in future!
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
from evtk.vtk import VtkFile, VtkGroup, VtkUnstructuredGrid
|
from evtk.vtk import VtkFile, VtkGroup, VtkUnstructuredGrid
|
||||||
from bdump import bdump
|
from bdump import bdump
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
|
|
||||||
from math import sin,cos,sqrt,pi,acos
|
from math import sin,cos,sqrt,pi,acos
|
||||||
from OpenGL.Tk import *
|
from OpenGL.Tk import *
|
||||||
|
|||||||
14
src/image.py
14
src/image.py
@ -11,7 +11,11 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, os, subprocess, re, glob
|
import sys, os, re, glob
|
||||||
|
try:
|
||||||
|
import commands
|
||||||
|
except ImportError:
|
||||||
|
import subprocess as commands
|
||||||
from math import *
|
from math import *
|
||||||
try:
|
try:
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
@ -138,7 +142,7 @@ class image:
|
|||||||
def convert(self,file1,file2,switch=""):
|
def convert(self,file1,file2,switch=""):
|
||||||
if file1.find('*') < 0 or file2.find('*') < 0:
|
if file1.find('*') < 0 or file2.find('*') < 0:
|
||||||
cmd = "%s %s %s %s" % (PIZZA_CONVERT,switch,file1,file2)
|
cmd = "%s %s %s %s" % (PIZZA_CONVERT,switch,file1,file2)
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
return
|
return
|
||||||
|
|
||||||
index = file1.index('*')
|
index = file1.index('*')
|
||||||
@ -156,7 +160,7 @@ class image:
|
|||||||
cmd = "%s %s %s %s" % (PIZZA_CONVERT,switch,file1,file2)
|
cmd = "%s %s %s %s" % (PIZZA_CONVERT,switch,file1,file2)
|
||||||
print(middle, end=' ')
|
print(middle, end=' ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
@ -170,7 +174,7 @@ class image:
|
|||||||
if fileargs[i].find('*') < 0:
|
if fileargs[i].find('*') < 0:
|
||||||
cmd = "%s %s" % (PIZZA_MONTAGE,switch)
|
cmd = "%s %s" % (PIZZA_MONTAGE,switch)
|
||||||
for j in range(nsets): cmd += " %s" % fileargs[j]
|
for j in range(nsets): cmd += " %s" % fileargs[j]
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
return
|
return
|
||||||
|
|
||||||
nfiles = len(glob.glob(fileargs[0]))
|
nfiles = len(glob.glob(fileargs[0]))
|
||||||
@ -194,7 +198,7 @@ class image:
|
|||||||
middle = re.search(expr,filesets[0][i]).group(1)
|
middle = re.search(expr,filesets[0][i]).group(1)
|
||||||
fileN = "%s%s%s" % (preN,middle,postN)
|
fileN = "%s%s%s" % (preN,middle,postN)
|
||||||
cmd += " %s" % fileN
|
cmd += " %s" % fileN
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
print(middle, end=' ')
|
print(middle, end=' ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
print()
|
print()
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, subprocess, re, glob, types
|
import sys, re, glob, types
|
||||||
import functools
|
import functools
|
||||||
from os import popen
|
from os import popen
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, subprocess, re, glob, types
|
import sys, re, glob, types
|
||||||
import functools
|
import functools
|
||||||
from os import popen
|
from os import popen
|
||||||
from math import * # any function could be used by set()
|
from math import * # any function could be used by set()
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
|
|
||||||
oneline = "Compute LAMMPS pairwise energies"
|
oneline = "Compute LAMMPS pairwise energies"
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
from math import sqrt,pi,cos,sin
|
from math import sqrt,pi,cos,sin
|
||||||
from data import data
|
from data import data
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
# modules needed by pizza.py
|
# modules needed by pizza.py
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, subprocess, os, string, glob, re
|
import sys, os, string, glob, re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# Help strings:
|
# Help strings:
|
||||||
@ -70,11 +70,13 @@ except ImportError as exception:
|
|||||||
|
|
||||||
nodisplay = False
|
nodisplay = False
|
||||||
try:
|
try:
|
||||||
|
import Tkinter
|
||||||
|
tkroot = Tkinter.Tk()
|
||||||
|
tkroot.withdraw()
|
||||||
|
except ImportError as exception:
|
||||||
import tkinter
|
import tkinter
|
||||||
tkroot = tkinter.Tk()
|
tkroot = tkinter.Tk()
|
||||||
tkroot.withdraw()
|
tkroot.withdraw()
|
||||||
except ImportError as exception:
|
|
||||||
nodisplay = True
|
|
||||||
pass
|
pass
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
nodisplay = True
|
nodisplay = True
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, re, glob, time
|
import sys, re, glob, time
|
||||||
try:
|
try:
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
|
|||||||
@ -11,7 +11,11 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, os, subprocess, re, types
|
import sys, os, re, types
|
||||||
|
try:
|
||||||
|
import commands
|
||||||
|
except ImportError:
|
||||||
|
import subprocess as commands
|
||||||
from pdbfile import pdbfile
|
from pdbfile import pdbfile
|
||||||
|
|
||||||
oneline = "3d visualization via RasMol program"
|
oneline = "3d visualization via RasMol program"
|
||||||
@ -120,7 +124,7 @@ class rasmol:
|
|||||||
# display the image
|
# display the image
|
||||||
|
|
||||||
cmd = "%s tmp.gif" % (PIZZA_DISPLAY)
|
cmd = "%s tmp.gif" % (PIZZA_DISPLAY)
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -192,8 +196,8 @@ class rasmol:
|
|||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
|
|
||||||
subprocess.getoutput("rm tmp*.pdb")
|
commands.getoutput("rm tmp*.pdb")
|
||||||
subprocess.getoutput("rm tmp*.rasmol")
|
commands.getoutput("rm tmp*.rasmol")
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,11 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, os, subprocess, re
|
import sys, os, re
|
||||||
|
try:
|
||||||
|
import commands
|
||||||
|
except ImportError:
|
||||||
|
import subprocess as commands
|
||||||
from vizinfo import vizinfo
|
from vizinfo import vizinfo
|
||||||
from math import fabs,atan,cos,sin
|
from math import fabs,atan,cos,sin
|
||||||
|
|
||||||
@ -233,7 +237,7 @@ class raster:
|
|||||||
|
|
||||||
self.single(0,self.file,box,atoms,bonds,tris,lines)
|
self.single(0,self.file,box,atoms,bonds,tris,lines)
|
||||||
cmd = "%s %s.png" % (PIZZA_DISPLAY,self.file)
|
cmd = "%s %s.png" % (PIZZA_DISPLAY,self.file)
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -443,7 +447,7 @@ class raster:
|
|||||||
else:
|
else:
|
||||||
cmd = "cat tmp.r3d | %s -png %s.png" % (PIZZA_LABEL3D,file)
|
cmd = "cat tmp.r3d | %s -png %s.png" % (PIZZA_LABEL3D,file)
|
||||||
|
|
||||||
output = subprocess.getoutput(cmd)
|
output = commands.getoutput(cmd)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|||||||
@ -11,7 +11,11 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, os, subprocess, re
|
import sys, os, re
|
||||||
|
try:
|
||||||
|
import commands
|
||||||
|
except ImportError:
|
||||||
|
import subprocess as commands
|
||||||
import functools
|
import functools
|
||||||
from vizinfo import vizinfo
|
from vizinfo import vizinfo
|
||||||
from math import sqrt,atan,cos,sin,fabs
|
from math import sqrt,atan,cos,sin,fabs
|
||||||
@ -204,7 +208,7 @@ class svg:
|
|||||||
|
|
||||||
self.single(self.file,box,atoms,bonds,tris,lines,1)
|
self.single(self.file,box,atoms,bonds,tris,lines,1)
|
||||||
cmd = "%s %s.svg" % (PIZZA_DISPLAY,self.file)
|
cmd = "%s %s.svg" % (PIZZA_DISPLAY,self.file)
|
||||||
subprocess.getoutput(cmd)
|
commands.getoutput(cmd)
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import sys, subprocess, re, glob, types
|
import sys, re, glob, types
|
||||||
import functools
|
import functools
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
from os import popen
|
from os import popen
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
try:
|
try:
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import types
|
import types
|
||||||
|
|
||||||
# Class definition
|
# Class definition
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
# Imports and external programs
|
# Imports and external programs
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
import types, os
|
import types, os
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user