Giter Club home page Giter Club logo

misc's People

Contributors

adamculp avatar anilgulecha avatar nonzero avatar tsveg1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

misc's Issues

SSHMenu: nested menu not read correctly

If you have a sshMenu config file with a multiple nested menu, the program not work correctly.
I fixed the program modifying the method get_sshmenuconfig() with the follow (for change search for stackMenuIndex):

'''
def get_sshmenuconfig():
if not os.path.exists(_SSHMENU_FILE):
return []
hostlist=open(_SSHMENU_FILE,"r").read()
lines = hostlist.split("\n")
lines.remove("items: ") #get rid of the first instance
app_list = []

smflag=0     # Flag to ignore submenu title items
smtitle=""   # To hold the title while searching for parameters
smparams=""  # To hold parameters values
stackMenuIndex = []

try:
    for line in lines:
        if re.search("title:",line):
            if smflag == 1:
                smtitle=line.split(":", 1)[1]
                continue
            smflag=1
            smtitle=line.split(":", 1)[1]

        elif re.search("sshparams:",line):
            smparams=line.split(":", 1)[1]
            smflag=2

        elif re.search("items:",line):
            app_list.append({
                'name': 'FOLDER',
                'cmd': "SSHmenu",
                'args':"",
            })
            #lastmenuindex = len(app_list) - 1
            stackMenuIndex.append(len(app_list) - 1)

        elif re.search("type: menu",line):
            if smflag == 1:
                #app_list[lastmenuindex]["cmd"] = smtitle
                app_list[stackMenuIndex.pop()]["cmd"] = smtitle
                app_list.append({
                'name': 'FOLDER',
                'cmd': "",
                'args':"",
            })
                smflag = 0

        if smflag == 2:
            arglist = ("-x ssh " + smparams).split(" ")
            for a in arglist:
                if a == "":
                    arglist.remove("")
            app_list.append({
                'name': smtitle,
                'cmd': 'gnome-terminal',
                'args': arglist,
             })
            smflag=0
    return app_list
except:
    print "error in line:" + line
    return []

'''

Bye

ValueError: list.remove(x): x not in list

dmd@rossum:~$ sshplus.py 
Traceback (most recent call last):
  File "/usr/local/bin/sshplus.py", line 264, in <module>
    appmenu = build_menu()
  File "/usr/local/bin/sshplus.py", line 229, in build_menu
    app_list2 = get_sshmenuconfig()
  File "/usr/local/bin/sshplus.py", line 127, in get_sshmenuconfig
    lines.remove("items: ") #get rid of the first instance
ValueError: list.remove(x): x not in list

dmd@rossum:~$ cat .sshplus 
up|gnome-terminal|-x ssh up
ubupci|gnome-terminal|-x ssh imt@ubupci
lumen|gnome-terminal|-x ssh [email protected]

What am I doing wrong here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.