Exemplo n.º 1
0
def do_main(argv=None):
    global relation_files
    relation_files = {}
    global not_exist_script
    not_exist_script = []
    
    global args_sign
    args_sign = True
    global type_list
    type_list = None
    
    if argv is None:
        argv = sys.argv
    parser = OptionParser(usage=get_usage())
    parser.add_option("-d", "--dictory",
                        action="callback",
                        type="string",
                        help="check file's call relationship in dir",
                        metavar="string",
                        callback=directory_option)
    parser.add_option("-f", "--file",
                        action="callback",
                        type="string",
                        help="check one file's call relationship",
                        metavar="FILE",
                        callback=file_option)
    parser.add_option("-c", "--configure",
                        action="callback",
                        type="string",
                        help="read configuration from FILE",
                        metavar="FILE",
                        callback=configure_option)
    parser.add_option("-t", "--type",
                        action="store_true",
                        help="file/script type such as: BASH, C, PERL, PYTHON, TXT")
    (options, args) = parser.parse_args(argv[1:])
    if args_sign:
        parser.print_help()
    else:
        for e in not_exist_script:
            print 'Not Exist Bash Script File: %s' % e
        print '='*100
        for (file, (file_relations, md5value)) in relation_files.items():
            print file_relations
        print '\n'
        print '='*100
        answer = raw_input('\n 是否存入到数据库中?yes or no:')
        if 'yes' in answer:
            #save to prdb
            from SaveToDB import MyDBTool
            try:
                mydb = MyDBTool(host='localhost', db='prdb', user='******', passwd='lizzie1985')
                mydb.some_prepare()
                mydb.save_relations(relation_files)
                print 'save to prdb correctly!\n'
            except Exception, e:
                print e
            finally:
Exemplo n.º 2
0
def save_to_db(relation_files):
            """save relation to prdb
            """
            from SaveToDB import MyDBTool
            mydb = None
            try:
                mydb = MyDBTool(host='localhost', db='prdb', user='******', passwd='lizzie1985')
                mydb.some_prepare()
                mydb.save_relations(relation_files)
                print 'save to prdb correctly!\n'
            except Exception, e:
                print e
Exemplo n.º 3
0
def save_to_db(relation_files):
    """save relation to prdb
            """
    from SaveToDB import MyDBTool
    mydb = None
    try:
        mydb = MyDBTool(host='localhost',
                        db='prdb',
                        user='******',
                        passwd='lizzie1985')
        mydb.some_prepare()
        mydb.save_relations(relation_files)
        print 'save to prdb correctly!\n'
    except Exception, e:
        print e
Exemplo n.º 4
0
def save_to_db(name, relation_files, create_flag=True):
    """save relation to prdb
    """
    from SaveToDB import MyDBTool
    mydb = None
    try:
        mydb = MyDBTool(host='localhost', db='prdb', user='******', passwd='lizzie1985')        ##需要修改密码
        if create_flag:
            mydb.some_prepare()                           #清空prdb
            mydb.save_relations(relation_files)
        else:
            mydb.some_prepare_other()                           #不清空prdb,递增数据
            mydb.save_relations(relation_files, mydb.get_fileid()+1)
        print 'save %s to prdb correctly!\n' % name
    except Exception, e:   #如果prdb不存在,这边就产生异常,退出程序
        print e
Exemplo n.º 5
0
def save_to_db(name, relation_files, create_flag=True):
    """save relation to prdb
    """
    from SaveToDB import MyDBTool
    mydb = None
    try:
        mydb = MyDBTool(host='localhost',
                        db='prdb',
                        user='******',
                        passwd='lizzie1985')  ##需要修改密码
        if create_flag:
            mydb.some_prepare()  #清空prdb
            mydb.save_relations(relation_files)
        else:
            mydb.some_prepare_other()  #不清空prdb,递增数据
            mydb.save_relations(relation_files, mydb.get_fileid() + 1)
        print 'save %s to prdb correctly!\n' % name
    except Exception, e:  #如果prdb不存在,这边就产生异常,退出程序
        print e
Exemplo n.º 6
0
def do_main(argv=None):
    global relation_files
    relation_files = {}
    global not_exist_script
    not_exist_script = []

    global args_sign
    args_sign = True
    global type_list
    type_list = None

    if argv is None:
        argv = sys.argv
    parser = OptionParser(usage=get_usage())
    parser.add_option("-d",
                      "--dictory",
                      action="callback",
                      type="string",
                      help="check file's call relationship in dir",
                      metavar="string",
                      callback=directory_option)
    parser.add_option("-f",
                      "--file",
                      action="callback",
                      type="string",
                      help="check one file's call relationship",
                      metavar="FILE",
                      callback=file_option)
    parser.add_option("-c",
                      "--configure",
                      action="callback",
                      type="string",
                      help="read configuration from FILE",
                      metavar="FILE",
                      callback=configure_option)
    parser.add_option(
        "-t",
        "--type",
        action="store_true",
        help="file/script type such as: BASH, C, PERL, PYTHON, TXT")
    (options, args) = parser.parse_args(argv[1:])
    if args_sign:
        parser.print_help()
    else:
        for e in not_exist_script:
            print 'Not Exist Bash Script File: %s' % e
        print '=' * 100
        for (file, (file_relations, md5value)) in relation_files.items():
            print file_relations
        print '\n'
        print '=' * 100
        answer = raw_input('\n 是否存入到数据库中?yes or no:')
        if 'yes' in answer:
            #save to prdb
            from SaveToDB import MyDBTool
            try:
                mydb = MyDBTool(host='localhost',
                                db='prdb',
                                user='******',
                                passwd='lizzie1985')
                mydb.some_prepare()
                mydb.save_relations(relation_files)
                print 'save to prdb correctly!\n'
            except Exception, e:
                print e
            finally: