print(str(err)) print(usage()) sys.exit(2) for opt, arg in opts: if opt == '-h': usage() sys.exit() elif opt in ("-c", "---classifier_id"): classifier_id = arg elif opt == '-d': DEBUG = True if not classifier_id: print('Required argument missing.') usage() sys.exit(2) try: # create classifiers with the training data natural_language_classifier = NaturalLanguageClassifier(url=nlcConstants.getUrl(), username=nlcConstants.getUsername(), password=nlcConstants.getPassword()) # Delete the classifier sys.stdout.write('Deleting the classifier %s ...\n' % classifier_id) res = natural_language_classifier.remove(classifier_id) sys.stdout.write('Response: \n%s\n' % json.dumps(res, indent=2)) except Exception as e: sys.stdout.write(str(e)) exit(1)
opts, args = getopt.getopt(sys.argv[1:], "hdv", []) except getopt.GetoptError as err: print(str(err)) print(usage()) sys.exit(2) for opt, arg in opts: if opt == '-h': usage() sys.exit() elif opt == '-d': DEBUG = True try: # list classifiers to get classifier_id natural_language_classifier = NaturalLanguageClassifier( url=nlcConstants.getUrl(), username=nlcConstants.getUsername(), password=nlcConstants.getPassword()) res = natural_language_classifier.list() sys.stdout.write('Response: \n%s\n' % json.dumps(res, indent=2)) # sys.stdout.write('Classifiers:\n') # sys.stdout.write('classifier_id,\tname,\tlanguage,\tcreated,\turl') # classifiers = res['classifiers'] # for classifier in classifiers: # sys.stdout.write('%s,\t%s,\t%s,\t%s,\t%s\n' % (classifier['classifier_id'], classifier['name'], classifier['language'], classifier['created'], classifier['url'])) except Exception as e: sys.stdout.write(str(e)) exit(1)