CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Difference between
modified post 1123 by jmeb on Thu 14th Jul 18:36 and
original post 1122 by jmeb on Thu 14th Jul 18:35
Show old version | new version | both versions

    
11
#! /usr/bin/env python
22
#
33
# A obpipemenu script for viewing a dir
44
# with a few options
55
#
77
import sys
88
import os
1010
###
1111
# Global Variables
1212
###
14-
DIRPRG = "thunar"       #Program to open directories
1514
VIDPRG = "vlc"         #Program to open files
16-
#Finish types implementation
17-
VIDTYPES = ( "avi", "mpg", "mkv", "m4v", "flv", )
1815
PYPIPE = str(os.path.abspath(__file__)) + " "
2118
def recent_file_list(src):
2219
    files = []
2320
    os.chdir(src)
2421
    # Get a list of tuples of filenames and their times modified.
2522
    for fn in os.listdir(src):
2623
        mtime = os.path.getmtime(os.path.abspath(fn))
2724
        timename = mtime, fn
2825
        files.append(timename)
2926
    # Sort the list by times, newest first
3027
    recenttuples = sorted(files, reverse=True)
3128
    # Get the names only, ina new list
3229
    recents = [ t[1] for t in recenttuples ]
3330
    return recents
3532
def printing(recents):
3633
    for f in recents:
3734
        if os.path.isdir(os.path.abspath(f)):
3835
            print_dir(f,PYPIPE)
3936
        else:
4037
            print_file(f,VIDPRG)
4239
def print_file(fn,prg):
4340
    print '<item label="%s...">' % fn[:20]
4441
    print '\t<action name="Execute">'
4542
    print "\t\t<execute>%s '%s' </execute>" % (prg, os.path.abspath(fn))
4643
    print '\t</action>'
4744
    print '</item>'
4946
def print_dir(src,pypipe):
5047
    print '<menu id="%s" label="%s..." execute="%s" />' % (src[:20],
5148
                                src[:20],pypipe + os.path.abspath(src))
5249
def main():
5451
    src = os.path.abspath(sys.argv[1])
5552
    recents = recent_file_list(src)
5653
    print "<openbox_pipe_menu>"
5754
    printing(recents)
5855
    print "</openbox_pipe_menu>"
6057
if __name__ == '__main__':
6158
    main()

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me