Exemplo n.º 1
0
def explore():

    print 'Loaded clr References:'
    print(clr.References)
    print ''

    print 'Using ipyver to see how things are loaded:'
    print ''

    if ipyver:
        rss = ipyver.ReferenceStatus('json')
        rsj = rss.RefStatus()
        for k, v in rss.RefStatusIPMS().iteritems():
            print(' {}:').format(k)
            for n, a in v.iteritems():
                print('   {}:{}').format(n, a)
        print ''
        for k, v in rsj.iteritems():
            print('   {}:{}').format(k, v)
        print ''
        rst = ipyver.ReferenceStatus('time')
        rstm = rst.RefStatus()
        for k, v in rstm.iteritems():
            print('   {}:{}').format(k, v)
        print ''
        rsr = ipyver.ReferenceStatus('re')
        rsre = rsr.RefStatus()
        for k, v in rsre.iteritems():
            print('   {}:{}').format(k, v)
        print ''
        rstd = ipyver.ReferenceStatus('StdLib')
        rstdlib = rstd.RefStatus()
        for k, v in rstdlib.iteritems():
            print('   {}:{}').format(k, v)
        print ''
        rclr = ipyver.ReferenceStatus('clr')
        rclrs = rclr.RefStatus()
        for k, v in rclrs.iteritems():
            print('   {}:{}').format(k, v)
        print ''

    print 'compare to inspect.getfile'

    try:
        print 'inspect ' + str(inspect.__file__)
        print 'inspect ' + str(inspect.getfile(version))
        print 'inspect ' + str(inspect.getfile(json))
    except Exception as ex:
        print(ex)

    print ''
    print 'Look at globals'
    glbls = list(globals())
    for g in glbls:
        print 'g: ' + str(g)
Exemplo n.º 2
0
def main():

    print('CurrentDirectory:\n '.format(IO.Directory.GetCurrentDirectory()))
    # we need the dll libraries we added to the dll list to run the following
    # Becasue they are embeded we load the auto-named internally embedded lib
    # mainname + DLL to get acces to the internal resources
    #
    # *OR* if you add the dendency files ipyver.py and make.py to the listexe
    # then you will not have a projectDLL and will not have to AddRef.
    # This only works if you have dependancies in .py format
    #
    # TODO the other way is to merge the stub .dll with the user lib .dll,
    # I don't know how to do that yet.

    try:
        clr.AddReference("makehello_embedDLL")
    except System.IO.IOException as ex:
        print('IOEX ', ex.Message)

    sysfile = System.__file__.split(',')
    System.Console.WriteLine(('HAVE SYSTEM:\n' + '{}\n'*len(sysfile)) \
                              .format(*sysfile))

    print "see clr refs"
    print clr.References
    print 'modules'
    for md in sys.modules:
        print(md)


#    import makehello_embed
#    print dir(makehello_embed)

    print 'mkh mods'
    #    for mh in dir(makehello_embed):
    #        print mh
    try:

        import ipyver  #from iypver.dll
        import inspect  #from stdlib or ipy sys.path
        import make  #from make lib

    except Exception as ex:
        print('err on import')
        print(ex)

    rsp = ipyver.ReferenceStatus('inspect').RefStatus()
    for k, v in rsp.iteritems():
        print('inspect {}:{}'.format(k, v))

    print('make dll from: {}'.format(inspect.getfile(make)))
    print('from make.hello - should get >>> "hello"')
    make.hello()

    from make import hello
    print('from make import hello - should get >>> "hello"')
    hello()
Exemplo n.º 3
0
def main():

    print('CurrentDirectory:\n {}'.format(
        System.IO.Directory.GetCurrentDirectory()))
    # we need the dll libraries we added to the dll list to run the following
    # Becasue they are embeded we load the auto-named internally embedded lib
    # mainname + DLL to get acces to the internal resources
    #
    # *OR* if you add the dendency files ipyver.py and make.py to the listexe
    # then you will not have a projectDLL and will not have to AddRef.
    # This only works if you have dependancies in .py format
    #
    # TODO the other way is to merge the stub .dll with the user lib .dll,
    # I don't know how to do that yet.

    clr.AddReference("makehello_aloneDLibDLL")
    import make
    import ipyver
    import inspect

    sysfile = System.__file__.split(',')
    System.Console.WriteLine(('HAVE SYSTEM:\n' + '{}\n'*len(sysfile)) \
                              .format(*sysfile))
    print
    print "clr refs"
    print clr.References
    print
    print 'library imports'
    for md in sys.modules:
        if md.find('make') != -1 or md.find('ipyv') != -1:
            print(md)
    print
    rsp = ipyver.ReferenceStatus('inspect').RefStatus()
    for k, v in rsp.iteritems():
        print('inspect {}:{}'.format(k, v))

    print
    print('make dll from: {}'.format(inspect.getfile(make)))
    print('from make.hello - should get >>> "hello"')
    make.hello()

    print
    from make import hello
    print('from make import hello - should get >>> "hello"')
    hello()
Exemplo n.º 4
0
def explore(argv):
    '''
      Run explore
       
      *Use ipy.exe and this file for debugging unusual errors*
      *Need ~1500 lines to see all listed output*
      **pipe to file** ``>> output.txt`` is better
    
      params:
    
      help: [-h, -?, /?, /h, help][op] :
    
      None [opt] - look at current IronPython imports status
      output: current contents of libimports manually updated:
        - Have Passed: Have been loaded as standalone in win8.1/win7 32/64
        - Direect: via import <libname>
        - Indirect: loaded as a results of "Direct" imports
        - Imported: list of current import libs by running this module
        - NotTested: Libraries and sub-Libraries not yet tested
        - New Added: If uncommented in NotTested and recomiled, run will have output
        - list of **current** index values in NotTested list to remove on success
        - Calc'd Indirect: Passed - Direct
    
      *current contents of libimports manually updated*
      -p [opt]  - Have Passed: Have been loaded as standalone in win8.1/win7 32/64
      -d [opt]  - Direect: via import <libname>
      -i [opt]  - Indirect: loaded as a results of "Direct" imports
      -n [opt]  - NotTested: Libraries and sub-Libraries not yet tested
      -v [opt]  - run ipyver to see where assemblies and modules are sourced.
      
    '''
    args = argv[1:]
    if args:
        if '-v' in args:
            import explorver
            print 'ipyver running'
            print ''
            explorver.explore()
            return

    sysmods = set(sys.modules)

    libimport = None
    havepassed = None
    print
    try:
        import libimport
    except Exception as expt:
        print 'fail import libimport in explorlib'
        print(expt)

    try:
        sysimportmods = set(sys.modules).union(sysmods)
    except Exception as ex:
        print(ex)

    if args:
        if '-p' in args:
            print 'libimport Passed'
            print ''
            print(libimport.Passed())
            return
        if '-d' in args:
            print 'libimport Direct'
            print ''
            print(libimport.Direct())
            return
        if '-i' in args:
            print 'libimport Indirect'
            print ''
            print(libimport.Indirect())
            return
        if '-n' in args:
            print 'libimport NotTested'
            print ''
            print(libimport.NotTested())
            return

    print
    rslib = ipyver.ReferenceStatus('libimport')
    rslibs = rslib.RefStatus()
    for k, v in rslibs.iteritems():
        print('   {}:{}').format(k, v)

    print
    print 'libimport Direct'
    print ''
    print(libimport.Direct())
    print ''
    print 'libimport Indirect'
    print ''
    print(libimport.Indirect())

    havepassed = libimport.Indirect() + '\n' + libimport.Direct()
    print ''
    print 'have passed should  == Passed'
    print
    print havepassed

    print 'Look at modules after imports'
    sysimportmods = sorted(sysimportmods)
    imported = ("',\n").join(["'" + si for si in sysimportmods])
    print ''
    print 'current imported'
    print imported
    print ''
    print 'new added'
    print
    for im in imported.split('\n'):
        imr = im.replace('"','').replace(',,',',').replace("'","") \
                .replace(',','').strip()
        if not any( imr in ima for ima in libimport.Indirect().split('\n')) and \
            not any( imr in imd for imd in libimport.Direct().split('\n')):
            print im

    print
    print 'Not Tested - skipped use -n [opt]'
    print
    #print libimport.NotTested()
    if havepassed:
        hasPassed = []
        for it, noT in enumerate(libimport.NotTested().split('\n')):
            basicImport = None
            dotImport = None
            if 'from' not in noT and ' as ' not in noT:
                basicImport = \
                    noT.replace('  ',' ') \
                    .replace('import ','') \
                    .replace("'","") \
                    .replace(',','') \
                    .strip()

            if 'from' in noT and ' as ' not in noT:
                dotImport = \
                    noT.replace('  ',' ') \
                    .replace(' import ','.') \
                    .replace('from ','') \
                    .replace("'","") \
                    .replace(',','') \
                    .strip()

            if ' as ' in noT:
                basicImport = \
                    noT.split(' as ')[1].replace('  ',' ') \
                    .replace("'","") \
                    .replace(',','') \
                    .strip()

            for hp in havepassed.split('\n'):
                testimport = None
                hpr = hp.replace('"','').replace(',,',',').replace("'","") \
                        .replace(',','').strip()
                testimport = basicImport if basicImport else dotImport
                if testimport and hpr:
                    if testimport.replace("'", "") == hpr:
                        hasPassed.append(('\n').join([
                            str(it + LINE),
                            noT.replace('"', '').replace(',', '')
                        ]))
        print
        print 'New Passed: Ready to clean from libimport NotTested list.'
        print 'Should be None unless you have new imports'
        print('\n').join(hasPassed)
Exemplo n.º 5
0
    try:
        clr.AddReference("StdLib")
    except System.IO.IOException as ex:
        print('StdLib.dll reference error:\n\t' + \
              'check file | filepath')
    try:
        clr.AddReference("IronPython")
    except System.IO.IOException as ex:
        print('IronPython reference error:\n\t' + \
              'check file | filepath')

    f_ipy = False
    try:
        import ipyver
        rs = ipyver.ReferenceStatus()
        f_ipy = rs.RefStatusIPMS()['ipy']['isLocal']
    except System.IO.IOException as ex:
        pass

    try:
        clr.AddReference("ipybuild")
    except System.IO.IOException as ex:
        try:
            clr.AddReference("ipybuilder")
        except System.IO.IOException as ex:
            if f_ipy:
                print('IF .exe: ipybuild(er) reference error:\n\t' + \
                      'check file | filepath')

#    if any(anarg in '-v' for anarg in sys.argv):
Exemplo n.º 6
0
def _subprocPYC(strCmd, cmpfile, dotExt='.dll'):

    clr = None # keep out global clr
    try:
        import clr    
    except Exception as ex:
        pass
    
    if clr:
        try:
            sys.path.append(oprel(compiler.pycpath))
            import pyc
        except Exception as ex:
            pass

        try:
            clr.AddReference("StdLib")
        except System.IO.IOException as ex:
            print('StdLib.dll reference error:\n\t' + \
                  'check file | filepath')
        try:
            clr.AddReference("IronPython")
        except System.IO.IOException as ex:
            print('IronPython reference error:\n\t' + \
                  'check file | filepath')
            
        f_ipy = False
        try:
            import ipyver
            rs = ipyver.ReferenceStatus()
            f_ipy = rs.RefStatusIPMS()['ipy']['isLocal']
        except System.IO.IOException as ex:
            pass
        
        try:
            clr.AddReference("ipybuild")
        except System.IO.IOException as ex:
            try:
                clr.AddReference("ipybuilder")
            except System.IO.IOException as ex:
                if f_ipy:
                    print('IF .exe: ipybuild(er) reference error:\n\t' + \
                          'check file | filepath')

        args = None
        rslt = None
        args = strCmd[2:]

        try:
            rslt = pyc.Main(args)
        except Exception as ex:
            errtyp = ''
            gsBuild.OK = False
            try:
                errtyp = ex.GetType().ToString()
            except Exception as exf:
                pass
            if ex:
                log.warn('pyc.Main err:\n' + ex.ToString())
                log.warn('type {} or System Type {}'.format(type(ex), errtyp))
                log.warn('Error: {}'.format(ex))
                print 'ex-err'

            return False
         
        if rslt:
            return True

    else:
        
        po = subprocess.Popen(strCmd, stdout=PIPE, stderr=PIPE)
        stdout, stderr = po.communicate()
        po.wait()

        if stderr:
            log.warn('ERR\n {}:\n\t compiling with {}'.format(stderr, cmpfile))
            po.kill()
            gsBuild.OK=False
            return False
     
        else:
            if gsBuild.Verbose or not gsBuild.INFO:
                log.info('\n - STDOUT - \n{}'.format(stdout))

        po.kill()
    
    if dotExt and opex(opj(opd(compiler.mainoutdir), 
                           opb(cmpfile).replace('.py', dotExt))):   
        log.FILE('Build Created: {}'.format(cmpfile.replace('.py', dotExt)))
        return True
    elif opex(cmpfile):
        log.FILE('Build Created: {}'.format(cmpfile))   
        return True
    else:
        gsBuild.OK = False
        return False
Exemplo n.º 7
0
except Exception as exs:
    pass

# reminds you
if clr:

    try:  # if you are not standalone catch (do not need if you know)
        clr.AddReference("IronPython")
        import IronPython
    except Exception as exc:
        print('"IronPython" not availible as AddReference')

    f_ipy = False
    try:
        import ipyver
        rs = ipyver.ReferenceStatus()
        f_ipy = rs.RefStatusIPMS()['ipy']['isLocal']
    except System.IO.IOException as ex:
        pass

    try:
        clr.AddReference("ipybuild")
    except System.IO.IOException as ex:
        try:
            clr.AddReference("ipybuilder")
        except System.IO.IOException as ex:
            if f_ipy:
                print('IF .exe: ipybuild(er) reference error:\n\t' + \
                      'check file | filepath')

from version import __version__