Skip to content

Commit

Permalink
Merge pull request #243 from danielepantaleone/release-1.10
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
thomasleveil committed Dec 20, 2014
2 parents 3f01d11 + e4fb824 commit e66b63a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
6 changes: 4 additions & 2 deletions b3/functions.py
Expand Up @@ -42,9 +42,10 @@
# - added left_cut function: remove the given prefix from a string
# - added right_cut function: remove the given suffix from a string
# - added hash_file function: calculate the MD5 digest of the given file
# 20/12/2014 - 1.15 - Fenix - fixed hash_file returning None

__author__ = 'ThorN, xlr8or, courgette'
__version__ = '1.14'
__version__ = '1.15'

import collections
import os
Expand Down Expand Up @@ -410,7 +411,8 @@ def hash_file(filepath):
Calculate the MD5 digest of a given file.
"""
with open(filepath, 'rb') as afile:
md5(afile.read()).hexdigest()
digest = md5(afile.read()).hexdigest()
return digest


def corrent_spell(c_word, wordbook):
Expand Down
21 changes: 14 additions & 7 deletions b3/plugins/cmdmanager.py
Expand Up @@ -23,9 +23,12 @@
# 18/09/2014 - 1.2 - Fenix - added command !cmdgrant: allow the execution of a command to a specific client
# - added command !cmdrevoke: revoke a previously given command grant
# - added command !cmduse: check whether a client can execute the given command
# 20/12/2014 - 1.3 - Fenix - fixed invalid placeholder in mysql related SQL statements
# - use client auth event instead of client connect: in client auth, client.id is not set
# and so we can't load command grants from the storage

__author__ = 'Fenix'
__version__ = '1.2'
__version__ = '1.3'

import b3
import b3.plugin
Expand All @@ -48,15 +51,16 @@
class CmdmanagerPlugin(b3.plugin.Plugin):

_adminPlugin = None
_frostBiteGameNames = ['bfbc2', 'moh', 'bf3', 'bf4']

_settings = {
'update_config_file': True
}

_sql = {
'mysql': {
'upsert': """REPLACE INTO cmdgrants (id, commands) VALUES (?, ?);""",
'select': """SELECT id, commands FROM cmdgrants WHERE id = ?""",
'upsert': """REPLACE INTO cmdgrants (id, commands) VALUES (%s, %s);""",
'select': """SELECT id, commands FROM cmdgrants WHERE id = %s""",
'schema': """CREATE TABLE IF NOT EXISTS cmdgrants (
id int(11) NOT NULL,
commands TEXT NOT NULL,
Expand Down Expand Up @@ -125,8 +129,11 @@ def onStartup(self):
protocol = self.console.storage.dsnDict['protocol']
self.console.storage.query(self._sql[protocol]['schema'])

# register the events needed
self.registerEvent(self.console.getEventID('EVT_CLIENT_CONNECT'), self.onConnect)
# register events needed
if self.console.gameName in self._frostBiteGameNames:
self.registerEvent(self.console.getEventID('EVT_PUNKBUSTER_NEW_CONNECTION'), self.onAuth)
else:
self.registerEvent(self.console.getEventID('EVT_CLIENT_AUTH'), self.onAuth)

# notice plugin started
self.debug('plugin started')
Expand All @@ -137,9 +144,9 @@ def onStartup(self):
## ##
####################################################################################################################

def onConnect(self, event):
def onAuth(self, event):
"""
Handle EVT_CLIENT_CONNECT events.
Handle EVT_CLIENT_AUTH events.
:param event: The Event to be handled
"""
self.load_command_grants(event.client)
Expand Down
7 changes: 5 additions & 2 deletions b3/plugins/updater.py
Expand Up @@ -28,9 +28,11 @@
# 16/12/2014 - 1.1.2 - Fenix - use EVT_PUNKBUSTER_NEW_CONNECTION instead of EVT_CLIENT_AUTH in Frostbite games
# 18/12/2014 - 1.1.3 - Fenix - catch exceptions when upgrading B3 database and warn users if some errors are generated
# while upgrading the B3 database
# 20/12/2014 - 1.1.4 - Fenix - added missing requiresConfigFile = False
# - removed useless debug message

__author__ = 'Fenix'
__version__ = '1.1.3'
__version__ = '1.1.4'

import b3
import b3.cron
Expand Down Expand Up @@ -71,6 +73,8 @@ def __repr__(self):

class UpdaterPlugin(b3.plugin.Plugin):

requiresConfigFile = False

_adminPlugin = None
_frostBiteGameNames = ['bfbc2', 'moh', 'bf3', 'bf4']
_re_filename = re.compile(r'''.+/(?P<archive_name>.+)''')
Expand Down Expand Up @@ -292,7 +296,6 @@ def install_update(self, update_data, update_basepath):

# this will hold the path in which we are going to copy files over
b3_current_path = os.path.join(b3_basepath, b3.functions.left_cut(root, update_basepath))
self.verbose('current b3 path: %s' % b3_current_path)

# create necessary directories in case there are new: those will be iterated
# later in the loop when a new root directory will be processed
Expand Down
6 changes: 4 additions & 2 deletions scripts/b3.sh
Expand Up @@ -2,7 +2,7 @@

# Big Brother Bot (B3) Management - http://www.bigbrotherbot.net
# Maintainer: Daniele Pantaleone <fenix@bigbrotherbot.net>
# App Version: 0.4
# App Version: 0.5
# Last Edit: 30/11/2014

### BEGIN INIT INFO
Expand All @@ -28,6 +28,7 @@
# auto-restart mode uses 4 processes (the screen, the main loop in b3/run.py, a new shell used #
# by subprocess, and the command to actually start the B3 instance inside this new shell), while #
# a normal B3 startup uses only 2 processes (screen and B3 process running inside the screen) #
# 2014-12-20 - 0.5 - fixed b3_clean not restarting all previously running B3 instances #
# #
########################################################################################################################

Expand Down Expand Up @@ -359,14 +360,15 @@ function b3_clean() {
fi
done

local B3_RUNNING_LIST=$(join ' ' "${B3_RUNNING[@]}")
find "$(readlink -f "../")" -type f \( -name "*.pyc" -o -name "*${PID_EXT}" \) \
-exec rm {} \; \
-exec printf "." \; \

echo " DONE!"

# restart all the B3 which were running
for i in ${B3_RUNNING}; do
for i in ${B3_RUNNING_LIST}; do
b3_start "${i}"
done

Expand Down

0 comments on commit e66b63a

Please sign in to comment.