def connect(): try: if cjdns_use_default: print('Connecting using default or ~/.cjdnsadmin credentials...') con = cjdns.connectWithAdminInfo() else: print('Connecting to port {:d}...'.format(cjdns_port)) con = cjdns.connect(cjdns_ip, cjdns_port, cjdns_password) return con except: print('Connection failed!') print(traceback.format_exc()) sys.exit(1)
def connect(): try: if cjdns_use_default: print('Connecting using default or ~/.cjdnsadmin credentials...') con = cjdns.connectWithAdminInfo() else: print('Connecting to port %d...' % (cjdns_port)) con = cjdns.connect(cjdns_ip, cjdns_port, cjdns_password) print(admin_tools.whoami(con)['IP']) return con except: print('Failed!') print(traceback.format_exc()) sys.exit(1)
#!/usr/bin/env python # You may redistribute this program and/or modify it under the terms of # the GNU General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """A simple script to test if the library can be imported and connect""" import cjdns cjdns = cjdns.connectWithAdminInfo() cjdns.ping()