diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-07-30 22:41:21 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-07-30 22:41:21 +0300 |
commit | 7c6f655c2e65eb0644ecec6f1bd508c954862711 (patch) | |
tree | fafb1f2a5baffe65e765b0a05d92b48ad561aa64 /segget/segget.conf | |
parent | Add options: GENERAL_LOG_TIME_FORMAT, ERROR_LOG_TIME_FORMAT and DEBUG_LOG_TIM... (diff) | |
download | idfetch-7c6f655c2e65eb0644ecec6f1bd508c954862711.tar.gz idfetch-7c6f655c2e65eb0644ecec6f1bd508c954862711.tar.bz2 idfetch-7c6f655c2e65eb0644ecec6f1bd508c954862711.zip |
Add [scripting_and_scheduling] section to segget.conf file.
[scripting_and_scheduling]
Segget provides Python scripting functionalyty to support scheduling.
Each time segget tries to start a new connection certain network it calls
a python script (client.py) to accept or reject this connection and
if necessary adjusts its settings.
PYTHON_PATH
Define path to python
Default:
python_path=/usr/bin/python
SCRIPTS_DIR
Define a path to the dir with python scripts. Before establishing connection for
a particular segment via network# segget checks SCRIPTS_DIR.
If SCRIPTS_DIR contains net#.py file, segget will launch schedule() function
from this file to apply settings for connetion and accept or reject this
segment for the moment. net#.py file is a python script file
with a user-writen schedule() function.
It's necessary to import functions before using get("variable"),
set("variable",value), accept_segment() and reject_segment() in schedule().
get() function can obtain values for the following variables:
connection.num, connection.url, connection.max_speed_limit,
network.num, network.mode, network.active_connections_count,
distfile.name, distfile.size, distfile.dld_segments_count,
distfile.segments_count, distfile.active_connections_count,
segment.num, segment.try_num, segment.size, segment.range
set() function can change connection.max_speed_limit, see example:
-----------------EXAMPLE STARTS-----------------
from functions import *
import time;
def schedule():
localtime = time.localtime(time.time());
hour=localtime[3];
# disable downloading distfiles that have size more than 5 000 000 bytes
# from 8-00 to 22-00.
if hour>8 and hour<22 and (get("distfile.size"))>5000000:
print "reject because distfile is too big"
reject_segment()
# set speed limit 50 000 cps for distfiles larger than 1 000 000 bytes
if get("distfile.size")>1000000:
print "limit connection speed"
set(connection.max_speed_limit, 50000)
accept_segment()
-----------------EXAMPLE ENDS-----------------
From example above localtime returns following tuple:
Index Attributes Values
0 tm_year e.i.: 2008
1 tm_mon 1 to 12
2 tm_mday 1 to 31
3 tm_hour 0 to 23
4 tm_min 0 to 59
5 tm_sec 0 to 61 (60 or 61 are leap-seconds)
6 tm_wday 0 to 6 (0 is Monday)
7 tm_yday 1 to 366 (Julian day)
8 tm_isdst -1, 0, 1, -1 means library determines DST
Therefore localtime[3] provides hours.
Segment will be accecpted by default if it was neither accepted nor rejected
during the schedule() function.
sagget saves logs of resulting stdout and stderr in the log folder
separatly for each network. Hence, if there's an error in net3.py file python
error message would be saved to net3_script_stderr.log. Results of print would
be saved in net3_script_stdout.log.
Default:
scripts_dir=./scripts
SCRIPT_SOCKET_PATH
Segget uses AF_UNIX domain sockets for communication with python.
Specify path for the socket on your filesystem.
Default:
script_socket_path=/tmp/segget_script_socket
Diffstat (limited to 'segget/segget.conf')
-rw-r--r-- | segget/segget.conf | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/segget/segget.conf b/segget/segget.conf index 4cac4a3..616ce1e 100644 --- a/segget/segget.conf +++ b/segget/segget.conf @@ -279,6 +279,81 @@ request_ip=127.0.0.1 # request_port=10000 request_port=10000 +[scripting_and_scheduling] +# Segget provides Python scripting functionalyty to support scheduling. +# Each time segget tries to start a new connection certain network it calls +# a python script (client.py) to accept or reject this connection and +# if necessary adjusts its settings. + +# PYTHON_PATH +# Define path to python +# Default: +# python_path=/usr/bin/python +python_path=/usr/bin/python + +# SCRIPTS_DIR +# Define path to a dir with python scripts. Before establishing connection for +# a particular segment via network# segget checks SCRIPTS_DIR. +# If SCRIPTS_DIR contains net#.py file, segget will launch schedule() function +# from this file to apply settings for connetion and accept or reject this +# segment for the moment. net#.py file is a causual python script file +# with a user-writen schedule() function. +# It's necessary to import functions before using get("variable"), +# set("variable",value), accept_segment() and reject_segment() in schedule(). +# get() function can obtain values for the following variables: +# connection.num, connection.url, connection.max_speed_limit, +# network.num, network.mode, network.active_connections_count, +# distfile.name, distfile.size, distfile.dld_segments_count, +# distfile.segments_count, distfile.active_connections_count, +# segment.num, segment.try_num, segment.size, segment.range +# set() function can change connection.max_speed_limit, see example: +# -----------------EXAMPLE STARTS----------------- +# from functions import * +# import time; +# def schedule(): +# localtime = time.localtime(time.time()); +# hour=localtime[3]; +# # disable downloading distfiles that have size more than 5 000 000 bytes +# # from 8-00 to 22-00. +# if hour>8 and hour<21 and (get("distfile.size"))>5000000: +# print "reject because distfile is too big" +# reject_segment() +# # set speed limit 50 000 cps for distfiles larger than 1 000 000 bytes +# if get("distfile.size")>1000000: +# print "limit connection speed" +# set(connection.max_speed_limit, 50000) +# accept_segment() +# -----------------EXAMPLE ENDS----------------- +# From example above localtime returns following tuple: +# Index Attributes Values +# 0 tm_year e.i.: 2008 +# 1 tm_mon 1 to 12 +# 2 tm_mday 1 to 31 +# 3 tm_hour 0 to 23 +# 4 tm_min 0 to 59 +# 5 tm_sec 0 to 61 (60 or 61 are leap-seconds) +# 6 tm_wday 0 to 6 (0 is Monday) +# 7 tm_yday 1 to 366 (Julian day) +# 8 tm_isdst -1, 0, 1, -1 means library determines DST +# Therefore localtime[3] provides hours. +# Segment will be accecpted by default if it was neither accepted nor rejected +# during the schedule() function. +# sagget saves logs of resulting stdout and stderr in the log folder +# separatly for each network. Hence, if there's an error in net3.py file python +# error message would be saved to net3_script_stderr.log. Results of print would +# be saved in net3_script_stdout.log. +# Default: +# scripts_dir=./scripts +scripts_dir=./scripts + +# script_socket_path +# Segget uses AF_UNIX domain sockets for communication with python. +# Specify path for the socket on your filesystem. +# NOTE !: Default value can NOT be changed yet (option under development). +# Default: +# script_socket_path=/tmp/segget_script_socket +script_socket_path=/tmp/segget_script_socket + [logs] # LOGS_DIR # Define a dir to store log files. |