Пример #1
0
def setByName(name):
    """set proxy by given name"""
    #check permission
    if not service.checkPermission():
        print "Error: set proxy failed. Permission denied!"
        exit(1)
    conn = service.getConnection()
    dao = ProxyDao(conn)
    p = dao.getProxyByName(name)
    conn.close()
    if not p:
        print "Error: The proxy name doesn't exist!"
    else:
        service.setproxy(p)
        print "Proxy was set successfully."
        print p
Пример #2
0
def setByName(name):
    
    """set proxy by given name"""
    #check permission
    if not service.checkPermission():
        print "Error: set proxy failed. Permission denied!"
        exit(1)
    conn  = service.getConnection() 
    dao   = ProxyDao(conn)
    p = dao.getProxyByName(name)
    conn.close()
    if not p:
        print "Error: The proxy name doesn't exist!"
    else:
        service.setproxy(p)
        print "Proxy was set successfully."
        print p
Пример #3
0
def set():
    """set proxy as current proxy (interactively)"""

    conn = service.getConnection()
    dao = ProxyDao(conn)
    __names(dao)  # print available proxy names
    print "---- Set proxy ----"
    p = None  # the proxy to be set
    while 1:
        name = raw_input("> Proxy name to be set: ")
        if not name:
            print "Error: name cannot be empty!"
        else:
            p = dao.getProxyByName(name)
            if not p:
                print "Error: The proxy name doesn't exist!"
            else:
                break

    conn.close()
    service.setproxy(p)
    print p
    print "---- Proxy set ----"
Пример #4
0
def set():
    """set proxy as current proxy (interactively)"""
    
    conn = service.getConnection()
    dao  = ProxyDao(conn)
    __names(dao) # print available proxy names
    print "---- Set proxy ----"
    p = None # the proxy to be set
    while 1:
        name = raw_input("> Proxy name to be set: ")
        if not name :
            print "Error: name cannot be empty!"
        else:
            p = dao.getProxyByName(name)
            if not p:
                print "Error: The proxy name doesn't exist!"
            else:
                break
    
    conn.close()
    service.setproxy(p)
    print p
    print "---- Proxy set ----"