You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Copyright (c) 2012-2013 by nils_2 <weechatter@arcor.de>
#
# Display size of current logfile in item-bar
#
# This program is free software; you can redistribute it 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/>.
#
# 2013-01-07: nils_2 (freenode.#weechat)
# 0.3 : missing logfile caused a crash (thanks swimmer)
# : add support of more than one window
# : two new options "log_disabled" and "file_not_found"
# 2012-11-22: nils_2 (freenode.#weechat)
# 0.2 : bug on first startup removed (thanks swimmer)
# 2012-01-14: nils_2 (freenode.#weechat)
# 0.1 : initial release
#
# How to use:
# add item "logsize" to option "weechat.bar.status.items"
#
# CAVE:
# USE OPTION: plugins.var.python.logsize.display "lines" VERY CAREFULLY
# Very large logfiles will stall script and weechat.
#
# Development is currently hosted at
# https://github.com/weechatter/weechat-scripts
try:
importweechat
importos, os.path, stat, time
fromdatetimeimportdate, timedelta
exceptException:
print"This script must be run under WeeChat."
print"Get WeeChat now at: http://www.weechat.org/"
quit()
SCRIPT_NAME="logsize"
SCRIPT_AUTHOR="nils_2 <weechatter@arcor.de>"
SCRIPT_VERSION="0.3"
SCRIPT_LICENSE="GPL"
SCRIPT_DESC="display size of current logfile in item-bar"
OPTIONS= { "refresh" : ("60","refresh timer (in seconds)"),
"size" : ("KB","display length in KB/MB/GB/TB. Leave option empty for byte"),
"display" : ("length","could be \"length\", \"lines\" or \"both\". CAVE: Use display option \"lines\" very carefully, large logfiles can stall the script and weechat!!!"),
"log_disabled" : ("","displays a text in item, when logger is disabled for buffer"),
"file_not_found": ("","displays a text in item, when logfile wasn't found"),
}
hooks= { "timer": "", "bar_item": "" }
# ================================[ dos ]===============================
defsizecheck(logfile):
ifnotos.path.isfile(logfile):
returnOPTIONS["file_not_found"]
filesize=float(os.path.getsize(logfile)) # filesize in bytes