Changeset 3166


Ignore:
Timestamp:
Nov 29, 2017 10:38:49 PM (6 years ago)
Author:
toby
Message:

Misc Py3 fixes

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/find_undoc.py

    r2027 r3166  
    3636        continue
    3737    else:
    38         print fil+' undocumented'
     38        print(fil+' undocumented')
    3939        undoc.append(fil)
    4040# generate code to place in a .rst file
    4141if undoc:
    42     print "\n# place this code somewhere in the .rst files\n#"
     42    print("\n# place this code somewhere in the .rst files\n#")
    4343for fil in undoc:
    44     print ".. automodule:: "+os.path.splitext(os.path.split(fil)[1])[0]
    45     print "    :members: "
    46     print ""
     44    print(".. automodule:: "+os.path.splitext(os.path.split(fil)[1])[0])
     45    print("    :members: ")
     46    print("")
  • trunk/makeBat.py

    r2803 r3166  
    5555    # Bob reports a problem using pythonw.exe w/Canopy on Windows, so change that if used
    5656    if pythonexe.lower().endswith('pythonw.exe'):
    57         print "  using python.exe rather than "+pythonexe
     57        print("  using python.exe rather than "+pythonexe)
    5858        pythonexe = os.path.join(os.path.split(pythonexe)[0],'python.exe')
    59         print "  now pythonexe="+pythonexe
     59        print("  now pythonexe="+pythonexe)
    6060    # create a GSAS-II script
    6161    fp = open(os.path.join(G2bat),'w')
     
    6868    fp.write(Script.format(pexe,G2s))
    6969    fp.close()
    70     print '\nCreated GSAS-II batch file RunGSASII.bat in '+gsaspath
     70    print('\nCreated GSAS-II batch file RunGSASII.bat in '+gsaspath)
    7171
    7272    # Associate a script and icon with .gpx files
     
    8484    winreg.CloseKey(openkey)
    8585    winreg.CloseKey(gpxkey)
    86     print 'Assigned icon and batch file to .gpx files'
     86    print('Assigned icon and batch file to .gpx files')
    8787
    8888    try:
     
    9191            win32com.shell.shellcon.SHCNE_ASSOCCHANGED, 0, None, None)
    9292    except ImportError:
    93         print 'Module pywin32 not present, login again to see file types properly'
     93        print('Module pywin32 not present, login again to see file types properly')
    9494    except:
    95         print 'Unexpected error on explorer refresh. Please report:'
     95        print('Unexpected error on explorer refresh. Please report:')
    9696        import traceback
    97         print traceback.format_exc()
     97        print(traceback.format_exc())
    9898
    9999    # make a desktop shortcut to GSAS-II
     
    109109        shobj.IconLocation = G2icon
    110110        shobj.save()
    111         print 'Created shortcut to start GSAS-II on desktop'
     111        print('Created shortcut to start GSAS-II on desktop')
    112112    except ImportError:
    113         print 'Module pywin32 not present, will not make desktop shortcut'
     113        print('Module pywin32 not present, will not make desktop shortcut')
    114114    except:
    115         print 'Unexpected error making desktop shortcut. Please report:'
     115        print('Unexpected error making desktop shortcut. Please report:')
    116116        import traceback
    117         print traceback.format_exc()
     117        print(traceback.format_exc())
    118118   
  • trunk/makeMacApp.py

    r2803 r3166  
    151151    #print testout,errout
    152152    if testout.strip() != "OK":
    153         print 'Run of python app failed, resorting to non-app version of Python, Alas!'
    154         pythonapp = sys.executable
    155         # is this brain-dead Canopy 1.4.0, if so, switch to pythonw
    156         try:
    157             import canopy.version
    158             if canopy.version.version == '1.4.0':
    159                 print 'using pythonw for Canopy 1.4.0'
    160                 pythonapp = os.path.join(os.path.split(pythonapp)[0],'pythonw')
    161                 if not os.path.exists(pythonapp):
    162                     raise Exception('no pythonw here: '+pythonapp)
    163         except ImportError:
    164             pass
     153        print('Run of wx in python failed, looking for pythonw')
     154        pythonapp = os.path.join(os.path.split(sys.executable)[0],'pythonw')
     155        if not os.path.exists(pythonapp):
     156            raise Exception('no pythonw found with '+sys.executable)
    165157        newpython = pythonapp
    166158    else:
     
    179171    try:
    180172        subprocess.check_output(["osacompile","-o",apppath,shell],stderr=subprocess.STDOUT)
    181     except subprocess.CalledProcessError, msg:
    182         print '''Error compiling AppleScript.
    183         Report the next message along with details about your Mac to toby@anl.gov'''
    184         print msg.output
     173    except subprocess.CalledProcessError as msg:
     174        print('''Error compiling AppleScript.
     175        Report the next message along with details about your Mac to toby@anl.gov''')
     176        print(msg.output)
    185177        sys.exit()
    186178
  • trunk/scanCCD.py

    r3142 r3166  
    167167       
    168168        import histosigma2d as h2d
    169         print 'Begin image integration'
     169        print('Begin image integration')
    170170        scaley = self.data['pixel'][1]/1000.
    171171        tthStart,tthEnd,tthStep = self.data['2thScan']
     
    204204                            jBeg = jBlk*blkSize
    205205                            jFin = jBeg+blkSize               
    206                             print 'Process map block:',nBlk,iBlk,jBlk,' offset:',iBegi,' limits:',iBeg,iFin,jBeg,jFin
     206                            print('Process map block:',nBlk,iBlk,jBlk,' offset:',iBegi,' limits:',iBeg,iFin,jBeg,jFin)
    207207                            TA = Make2ThetaMap(self.data,(iBeg,iFin),(jBeg,jFin))           #2-theta & Y arrays & create position mask                       
    208208                            Block = image[iBeg-iBegi:iFin-iBegi,jBeg:jFin]
     
    224224                                break
    225225                else:
    226                     print 'file '+imagefile+' skipped'
     226                    print('file '+imagefile+' skipped')
    227227                    nBlk += N*N
    228228                    GoOn = dlg.Update(nBlk)[0]
     
    240240            dlg.Destroy()
    241241        Scale = np.sum(Qmat)/np.sum(H0)
    242         print 'SumI: ',np.sum(H0),' SumV: ',np.sum(Qmat),' Scale:',Scale
    243         print 'Integration complete'
    244         print "Elapsed time:","%8.3f"%(t1-t0), "s"
     242        print('SumI: ',np.sum(H0),' SumV: ',np.sum(Qmat),' Scale:',Scale)
     243        print('Integration complete')
     244        print("Elapsed time:","%8.3f"%(t1-t0), "s")
    245245        self.Hxyw = [H1,Scale*H0.T[0],np.sqrt(Qmat.T[0])]
    246         print 
     246        print()
    247247        self.PlotXY(self.Hxyw,True,type='Integration result')
    248248       
     
    252252            file = open(powderfile,'w')
    253253            file.write('#%s\n'%('from scanCCD image '+self.imagefiles[0]))
    254             print 'save powder pattern to file: ',powderfile
     254            print('save powder pattern to file: ',powderfile)
    255255            wx.BeginBusyCursor()
    256256            try:
     
    269269            finally:
    270270                wx.EndBusyCursor()
    271             print 'powder pattern file written'
     271            print('powder pattern file written')
    272272       
    273273        if not self.Hxyw:
     
    280280        try:
    281281            if dlg.ShowModal() == wx.ID_OK:
    282                 print dlg.GetFilename()
     282                print(dlg.GetFilename())
    283283                powderfile = dlg.GetPath()
    284284                if 'fxye' in powderfile:
  • trunk/testDeriv.py

    r2551 r3166  
    105105                G2mv.GenerateConstraints(groups,parmlist,self.varylist,self.constrDict,self.fixedList,self.parmDict)
    106106                self.UpdateControls(event)
    107                 print G2mv.VarRemapShow(self.varylist)
    108                 print 'Dependent Vary List:',self.depVarList
     107                print(G2mv.VarRemapShow(self.varylist))
     108                print('Dependent Vary List:',self.depVarList)
    109109        finally:
    110110            dlg.Destroy()
     
    165165            sortby = 'tottime'
    166166            ps = pstats.Stats(pr, stream=s).strip_dirs().sort_stats(sortby)
    167             print 'Profiler of function calculation; top 50% of routines:'
     167            print('Profiler of function calculation; top 50% of routines:')
    168168            ps.print_stats("GSASII",.5)
    169             print s.getvalue()
     169            print(s.getvalue())
    170170            fplot.plot(M,'r',label='M')
    171171            fplot.legend(loc='best')
     
    186186                ps = pstats.Stats(pr, stream=s).strip_dirs().sort_stats(sortby)
    187187                ps.print_stats("GSASII",.5)
    188                 print 'Profiler of '+name+' derivative calculation; top 50% of routines:'
    189                 print s.getvalue()
     188                print('Profiler of '+name+' derivative calculation; top 50% of routines:')
     189                print(s.getvalue())
    190190            M2 = dMdV[varyList.index(name)]
    191191            hplot.plot(M2,'b',label='analytic deriv')
    192192            mmin = np.min(dMdV[varyList.index(name)])
    193193            mmax = np.max(dMdV[varyList.index(name)])
    194             print 'parameter:',name,self.parmDict[name],delt,mmin,mmax
     194            print('parameter:',name,self.parmDict[name],delt,mmin,mmax)
    195195            if name in self.varylist:
    196196                self.values[self.varylist.index(name)] -= delt
  • trunk/testSSymbols.py

    r3000 r3166  
    100100                msg = 'Superspace Group Information'
    101101                G2G.SGMessageBox(self,msg,text,table).Show()
    102                 print 'Super spacegroup operators for '+SSGData['SSpGrp']
     102                print('Super spacegroup operators for '+SSGData['SSpGrp'])
    103103                for Op in SSGData['SSGOps']:
    104                     print G2spc.SSMT2text(Op).replace(' ','')
     104                    print(G2spc.SSMT2text(Op).replace(' ',''))
    105105                if SGData['SGInv']:                                 
    106106                    for Op in SSGData['SSGOps']:
    107107                        Op = [-Op[0],-Op[1]%1.]
    108                         print G2spc.SSMT2text(Op).replace(' ','')                                 
     108                        print(G2spc.SSMT2text(Op).replace(' ',''))
    109109            else:
    110110                text = [E+'\nSuperspace Group set to previous']
  • trunk/testinp/genhkltest.py

    r103 r3166  
    3030    #ms.show_summary()
    3131    spcg = ("%s" %  ms.space_group_info()).split(':')[0]
    32     print spcg
     32    print(spcg)
    3333    fp.write("'%s': [\n" % spcg)
    3434    fp.write("%s ,\n" % ms.unit_cell())
     
    3737        if hkllist.has_key(d):
    3838            hkllist[d].append(hkl)
    39             print hkllist[d]
     39            print(hkllist[d])
    4040        else:
    4141            hkllist[d] = [hkl,]
     
    8989    if len(spcglist) > 1:
    9090        if spcglist[1] == 'R': spcg += ' R'
    91     print spcg
     91    print(spcg)
    9292    #fp.write("'%s': [\n" % spcg)
    9393    fp.write("'%s': [\n" % sg)
  • trunk/unit_tests.py

    r1077 r3166  
    3535    test_GSASIIspc()
    3636    test_GSASIIlattice()
    37     print "OK"
     37    print("OK")
Note: See TracChangeset for help on using the changeset viewer.