Esempio n. 1
0
'''@package network Python module for easy networking.
This module intends to make networking easy.  It supports tcp and unix domain
sockets.  Connection targets can be specified in several ways.
'''

# {{{ Imports.
import math
import sys
import os
import socket
import select
import re
import time
import fhs
fhs.module_init('network', {'tls': ''})
import traceback

try:
	import ssl
	have_ssl = True
except:
	have_ssl = False
# }}}

# {{{ Interface description
# - connection setup
#   - connect to server
#   - listen on port
# - when connected
#   - send data
Esempio n. 2
0
# Webgame module.
# vim: set foldmethod=marker :

# Imports. {{{
import websocketd
from websocketd import log
import fhs
import sys
import os
import time
import json
import __main__
import collections
# }}}

fhs.module_init('webgame', {'port': 8891, 'tls': False})

server = None

# Shared object handling. {{{
class Shared_Object(collections.MutableMapping): # {{{
	def __init__(self, path, target, group):
		self.__dict__['_path'] = path
		self.__dict__['_target'] = target
		self.__dict__['_members'] = {}
		self.__dict__['_alive'] = False
		self.__dict__['_group'] = group
	def __setattr__(self, key, value):
		if key in self._members and isinstance(self._members[key], (Shared_Object, Shared_Array)):
			self._members[key]._die()
		self._members[key] = make_shared(self._path, self._target, key, value, send = self._alive, group = self._group)
Esempio n. 3
0
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# }}}

# {{{ Imports.
import math
import sys
import os
import socket
import select
import re
import time
import fhs
fhs.module_init('network', {'tls': ''})
import traceback

try:
	import ssl
	have_ssl = True
except:
	have_ssl = False
try:
	import avahi
	import dbus
	from dbus.mainloop.glib import DBusGMainLoop
	have_avahi = True
except:
	have_avahi = False
# }}}