How to use the common.log function in common

To help you get started, we’ve selected a few common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xd34db33f / gfyp / core.py View on Github external
def main():
    """Description: Search for new domain variants and email alerts for new ones.
    """
    args = get_args()
    #Get configuration from env variables or fallback to hard-coded values
    smtp_auth = dict()
    smtp_auth['username'] = os.getenv('GFYP_EMAIL_USERNAME', EMAIL_USERNAME)
    smtp_auth['password'] = os.getenv('GFYP_EMAIL_PASSWORD', EMAIL_PASSWORD)
    smtp_auth['server'] = os.getenv('GFYP_EMAIL_SMTPSERVER', EMAIL_SMTPSERVER)
    for key, value in list(smtp_auth.items()):
        if value is None:
            msg = "Fatal error: Email setting '%s' has not been set." % key
            log(msg, logging.ERROR)
            sys.exit(msg)

    if any([EMAIL_USERNAME, EMAIL_PASSWORD, EMAIL_SMTPSERVER]):
        msg = ("WARNING: You have hard-coded credentials into a code file. Do "
               "not commit it to a public Git repo!")
        print(msg)
        log(msg, logging.WARNING)

    with gfyp_db.DatabaseConnection() as db_con:
        if db_con.is_db_current():
            domain_entries = db_con.get_watch_entries()

            if len(domain_entries) == 0:
                msg = ("No domains have been added for watching/alerts. Use "
                       "util.py to add domains.")
                print(msg)
github 0x90 / wifuzz / wifuzz.py View on Github external
if 'h' in opts or 's' not in opts or len(args) != 1:
        showhelp()
        exit(0)

    fuzztype    = args[0]
    conf.iface  = opts.get('i', DEFAULT_IFACE)
    conf.tping  = opts.get('p', DEFAULT_PING_TIMOUT)

    if not conf.tping.isdigit():
        log("[!] Ping timeout (-p) must be a valid integer", "MAIN")
        exit(2)

    conf.tping = int(conf.tping)
    if conf.tping <= 0:
        log("[!] Ping timeout (-p) must be greater than zero", "MAIN")
        exit(2)

    conf.outdir = opts.get('o', DEFAULT_PCAP_DIR)
    ssid        = opts.get('s')
    localmac    = str2mac(get_if_raw_hwaddr(conf.iface)[1])
    testmode    = 't' in opts
    
    log("Target SSID: %s; Interface: %s; Ping timeout: %d; PCAP directory: %s; Test mode? %s; Fuzzer(s): %s;" % \
            (ssid, conf.iface, conf.tping, conf.outdir, testmode, fuzztype), "MAIN")

    wifi = WifiDriver(ssid = ssid, tping = conf.tping, outdir = conf.outdir,
                      localmac = localmac, testmode = testmode, verbose = 1)

    # Get the MAC address of the AP
    try:
        mac = wifi.waitForBeacon()
github mrknow / filmkodi / plugin.video.mrknow / lib / main.py View on Github external
def clearCache(self):
        cacheDir = common.Paths.cacheDir
        if not os.path.exists(cacheDir):
            os.mkdir(cacheDir, 0777)
            common.log('Cache directory created' + str(cacheDir))
        else:
            fu.clearDirectory(cacheDir)
            common.log('Cache directory purged')
github yxw19870806 / PyCrawler / backup_urllib2 / googlePlus.py View on Github external
time.sleep(10)

        # 未完成的数据保存
        if len(ACCOUNTS) > 0:
            new_save_data_file = open(NEW_SAVE_DATA_PATH, "a")
            for account_id in ACCOUNTS:
                new_save_data_file.write("\t".join(account_list[account_id]) + "\n")
            new_save_data_file.close()

        # 删除临时文件夹
        self.finish_task()

        # 重新排序保存存档文件
        robot.rewrite_save_file(NEW_SAVE_DATA_PATH, self.save_data_path)

        log.step("全部下载完毕,耗时%s秒,共计图片%s张" % (self.get_run_time(), TOTAL_IMAGE_COUNT))
github fangli / collector-fluentd / libs / collectorfluentd.py View on Github external
def sendAllCache(self, sock):
        log("Sending all cached message to remote server...", -1)
        while True:
            fname, msg = self._getCachedMsg()
            if fname:

                log("Sending cache file %s to server..." % os.path.basename(fname), -1)

                for _msg in msg:
                    if not sock.send(_msg):
                        self.logError("collector.error.send")
                        log("Could not connect to the fluentd server, metrics will be sent next time.", 2)
                        return False

                log("Successful sent metrics to server in cache file %s" % os.path.basename(fname), -1)
                os.remove(fname)
            else:
                return True
github jaws / jaws / jaws / promice2nc.py View on Github external
def promice2nc(args, input_file, output_file, stations):
    df = init_dataframe(args, input_file)
    ds = xr.Dataset.from_dataframe(df)
    ds = ds.drop('time')

    common.log(args, 2, 'Retrieving latitude, longitude and station name')
    latitude, longitude, station_name = get_station(args, input_file, stations)

    common.log(args, 3, 'Calculating time and sza')
    time, time_bounds, sza, az = get_time_and_sza(args, df, longitude, latitude)

    common.log(args, 4, 'Converting lat_GPS and lon_GPS')
    convert_coordinates(args, df)

    common.log(args, 5, 'Calculating ice velocity')
    fill_ice_velocity(args, df, ds)

    ds['time'] = 'time', time
    ds['time_bounds'] = ('time', 'nbnd'), time_bounds
    ds['sza'] = 'time', sza
    ds['az'] = 'time', az
    ds['station_name'] = tuple(), station_name
github deanishe / alfred-relative-dates / src / reldate.py View on Github external
def main(wf):
    import common
    common.log = log

    log.debug('-' * 40)

    common.set_locale()

    lc, encoding = locale.getlocale()
    log.debug('args : {}'.format(wf.args))
    log.debug('locale : {}  encoding : {}'.format(lc, encoding))

    if len(wf.args):
        query = wf.args[0]
    else:
        query = None

    log.debug('query : {}'.format(query))
github jaws / jaws / jaws / nsidc2nc.py View on Github external
def nsidc2nc(args, input_file, output_file, stations):
    """Main function to convert NSIDC txt file to netCDF"""
    df, temperature_vars, pressure_vars = init_dataframe(args, input_file)
    ds = xr.Dataset.from_dataframe(df)
    ds = ds.drop('time')

    common.log(args, 2, 'Retrieving latitude, longitude and station name')
    latitude, longitude, station_name, elevation, qlty_ctrl = get_station(args, input_file, stations)

    common.log(args, 3, 'Calculating time and sza')
    time, time_bounds, sza, day_of_year = get_time_and_sza(args, df, latitude, longitude)

    ds['day_of_year'] = 'time', day_of_year
    ds['time'] = 'time', time
    ds['time_bounds'] = ('time', 'nbnd'), time_bounds
    ds['sza'] = 'time', sza
    ds['station_name'] = tuple(), station_name
    ds['latitude'] = tuple(), latitude
    ds['longitude'] = tuple(), longitude
    ds['elevation'] = tuple(), elevation

    comp_level = args.dfl_lvl

    common.load_dataset_attributes('nsidc', ds, args, temperature_vars=temperature_vars, pressure_vars=pressure_vars,
                                   qlty_ctrl=qlty_ctrl)
    encoding = common.get_encoding('nsidc', common.get_fillvalue(args), comp_level, args)
github mrknow / filmkodi / script.module.xbmcfilm / lib / main.py View on Github external
if not os.path.exists(common.Paths.pluginDataDir):
            os.makedirs(common.Paths.pluginDataDir, 0777)

        self.favouritesManager = FavouritesManager(common.Paths.favouritesFolder)
        self.customModulesManager = CustomModulesManager(common.Paths.customModulesDir, common.Paths.customModulesRepo)
        
        if not os.path.exists(common.Paths.customModulesDir):
            os.makedirs(common.Paths.customModulesDir, 0777)

        self.parser = Parser()
        self.currentlist = None
        
        self.addon = None
        
        common.log('SportsDevil initialized')
github ianmacd / beyond2lte / scripts / rkp_cfp / debug.py View on Github external
def err(list_of_args, msg, error):
        with lock:
            if len(list_of_args) > 0:
                log(textwrap.dedent(msg))
                for args in list_of_args:
                    log()
                    log(error(*args).rstrip('\n'))
                success.value = False