Пример #1
0
def compile_app(appname):
    #check python Versions
    print('Compiling app...')
    py3 = appname + '/Contents/Frameworks/python/3.5.0/bin/python'
    pypath = appname + '/Contents/Resources'
    if exists(py3):
        print('python3 detected...')
        check_call(
            [pypath + '/script -OO -m compileall -b ' + pypath+'/yourapp'],
            shell=True)
        print("Remove all __pycache__")
        check_call(
            ['find -E {} -regex "(.*)\.py" -print0 | xargs -0 rm'.format(pypath+'/yourapp')],
             shell=True)
        check_call(
            ['find -E {}/Contents/ -name "__pycache__" -print0 | xargs -0 rm -rf'.format(appname)],
            shell=True)
    else:
        print('using system python...')
        check_call(
            [pypath + '/script -OO -m compileall ' + appname],
            shell=True)
        print("-- Remove all py/pyc")
        check_call(
            ['find -E {} -regex "(.*)\.pyc" -print0 | xargs -0 rm'.format(appname)],
            shell=True)
        check_call(
            ['find -E {} -regex "(.*)\.py" -print0 | xargs -0 rm'.format(appname)],
            shell=True)
    sh.command('mv', pypath + '/myapp', pypath + '/yourapp')
Пример #2
0
def compile_app(appname):
    #check python Versions
    print('Compiling app...')
    py3 = appname + '/Contents/Frameworks/python/3.5.0/bin/python'
    pypath = appname + '/Contents/Resources'
    if exists(py3):
        print('python3 detected...')
        check_call(
            [pypath + '/script -OO -m compileall -b ' + pypath + '/myapp'],
            shell=True)
        print("Remove all __pycache__")
        check_call([
            '/usr/bin/find -E {} -regex "(.*)\.py" -print0 |/usr/bin/grep -v __init__| /usr/bin/xargs -0 /bin/rm'
            .format(pypath + '/yourapp')
        ],
                   shell=True)
        check_call([
            '/usr/bin/find -E {}/Contents/ -name "__pycache__" -print0 | /usr/bin/xargs -0 /bin/rm -rf'
            .format(appname)
        ],
                   shell=True)
    else:
        print('using system python...')
        check_call([pypath + '/script -OO -m compileall ' + pypath + '/myapp'],
                   shell=True)
        print("-- Remove all py/pyc/pyo")
        check_call([
            '/usr/bin/find -E {} -regex "(.*)\.pyc" -print0 | /usr/bin/xargs -0 /bin/rm'
            .format(appname)
        ],
                   shell=True)
        check_call([
            '/usr/bin/find -E {} -regex "(.*)\.pyo" -print0 | /usr/bin/xargs -0 /bin/rm'
            .format(appname)
        ],
                   shell=True)
        check_call([
            '/usr/bin/find -E {} -regex "(.*)\.py" -print0 | /usr/bin/grep -v __init__ | /usr/bin/xargs -0 /bin/rm'
            .format(appname)
        ],
                   shell=True)
        print("-- Remove all .c")
        check_call([
            '/usr/bin/find -E {} -regex "(.*)\.c" -print0 | /usr/bin/xargs -0 /bin/rm'
            .format(appname)
        ],
                   shell=True)
    sh.command('mv', pypath + '/myapp', pypath + '/yourapp')
Пример #3
0
def setup_icon(path_to_app, path_to_icon):
    # check icon file
    from subprocess import check_output
    if path_to_icon.startswith('http'):
        print('Downloading ' + path_to_icon)
        check_output(['curl', '-O', '-L', path_to_icon])
        path_to_icon = path_to_icon.split('/')[-1]
    if not exists(path_to_icon):
        return
    height = check_output(['sips', '-g', 'pixelHeight', path_to_icon])[-5:]
    width = check_output(['sips', '-g', 'pixelHeight', path_to_icon])[-5:]
    if height != width:
        print('The height and width of the image must be same')
        import sys
        sys.exit()

    # icon file is Finder
    sh.command('sips', '-s', 'format', 'icns', path_to_icon, '--out',
        path_to_app + "/Contents/Resources/appIcon.icns")
    print('Icon set to {}'.format(path_to_icon))
Пример #4
0
def setup_icon(path_to_app, path_to_icon):
    # check icon file
    from subprocess import check_output
    if path_to_icon.startswith('http'):
        print('Downloading ' + path_to_icon)
        check_output(['curl', '-O', '-L', path_to_icon])
        path_to_icon = path_to_icon.split('/')[-1]
    if not exists(path_to_icon):
        return
    height = check_output(['sips', '-g', 'pixelHeight', path_to_icon])[-5:]
    width = check_output(['sips', '-g', 'pixelHeight', path_to_icon])[-5:]
    if height != width:
        print('The height and width of the image must be same')
        import sys
        sys.exit()

    # icon file is Finder
    sh.command('sips', '-s', 'format', 'icns', path_to_icon, '--out',
        path_to_app + "/Contents/Resources/appIcon.icns")
    print('Icon set to {}'.format(path_to_icon))
Пример #5
0
def scan(interface):
    '''Gets the a list if networks and signal strength using iwlist'''
    if _platform == "linux" or _platform == "linux2":
        try:
            output = sh.iwlist(interface, 'scanning')
        except sh.ErrorReturnCode_255:
            raise WiFiScannerException('Interface is busy')
        BSSIDs = []
        ESSIDs = []
        RSSIs = []
        BSSID_line = re.compile(r'Address: ([0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2})')
        ESSID_line = re.compile(r'ESSID:"(.*)"')
        RSSI_line = re.compile(r'Signal level=(-\d+)')
        for line in output:
            m = re.search(BSSID_line, line)
            if m:
                BSSIDs.append(m.group(1))
                continue
            m = re.search(RSSI_line, line)
            if m:
                RSSIs.append(int(m.group(1)))
                continue
            m = re.search(ESSID_line, line)
            if m:
                ESSIDs.append(m.group(1))
                if len(BSSIDs) != len(RSSIs) or len(BSSIDs) != len(ESSIDs):
                    print(BSSIDs)
                    print(RSSIs)
                    print(ESSIDs)
                    raise WiFiScannerException('Mismatch between BSSIDs and RSSIs')
            continue
        return zip(BSSIDs, ESSIDs, RSSIs)
    elif _platform == "darwin":
        output = sh.command(r'/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport', '-s')
        BSSIDs = []
        ESSIDs = []
        RSSIs = []
        for line in output:
            match = re.search(r'\s*(.*) ([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}) (-?\d{1,2})', line)
            if match:
                ESSIDs.append(match.group(1))
                BSSIDs.append(match.group(2))
                RSSIs.append(int(match.group(3)))
        return zip(BSSIDs, ESSIDs, RSSIs)
    elif _platform == "win32":
        raise NotImplementedError('Windows is not yet supported')
        pass
Пример #6
0
import sh
import os

fp = "./input"
for fname in os.listdir(fp):
    fname = os.path.join(fp, fname)
    if fname.endswith('.pdf'):
        #sh.command('convert', fname, fname.replace('pdf', 'png'))
        sh.command('convert', '-density', '350', fname,
                   fname.replace('pdf', 'png'))

sh.command('generate-md',
           '--layout mixu-page --input ./input  --output ./output')

# mixu-book
# toc
Пример #7
0
import sh
import os

fp = "./input"
for fname in os.listdir(fp):
    fname = os.path.join(fp, fname)
    if fname.endswith('.pdf'):
        #sh.command('convert', fname, fname.replace('pdf', 'png'))
        sh.command('convert', '-density', '350', fname, fname.replace('pdf', 'png'))

sh.command('generate-md', '--layout mixu-page --input ./input  --output ./output')

# mixu-book
# toc