예제 #1
0
파일: lock.py 프로젝트: jortel/gofer
 def __init__(self, path):
     """
     :param path: The absolute path to the lock file.
     :type path: str
     """
     self.path = path
     self.__fp = None
     mkdir(os.path.dirname(path))
예제 #2
0
 def __init__(self, path):
     """
     :param path: The absolute path to the lock file.
     :type path: str
     """
     self.path = path
     self.__fp = None
     mkdir(os.path.dirname(path))
예제 #3
0
파일: plugin.py 프로젝트: pombreda/gofer
 def install():
     """
     Install the descriptor.
     """
     mkdir(os.path.dirname(Builtin.PATH))
     fp = open(Builtin.PATH, 'w+')
     try:
         for line in Builtin.DESCRIPTOR.split('\n'):
             fp.write(line.strip())
             fp.write('\n')
     finally:
         fp.close()
예제 #4
0
파일: plugin.py 프로젝트: pombreda/gofer
 def install():
     """
     Install the descriptor.
     """
     mkdir(os.path.dirname(Builtin.PATH))
     fp = open(Builtin.PATH, 'w+')
     try:
         for line in Builtin.DESCRIPTOR.split('\n'):
             fp.write(line.strip())
             fp.write('\n')
     finally:
         fp.close()
예제 #5
0
파일: store.py 프로젝트: pombreda/gofer
 def _open(self):
     """
     Open for operations.
     Load journal(ed) requests. These are requests were in the queuing pipeline
     when the process was terminated. put() is blocked until this has completed.
     """
     path = os.path.join(Pending.PENDING, self.stream)
     mkdir(path)
     log.info('Using: %s', path)
     for path in self._list():
         log.info('Restoring: %s', path)
         request = Pending._read(path)
         if not request:
             # read failed
             continue
         self._put(request, path)
     self.is_open = True
예제 #6
0
 def _open(self):
     """
     Open for operations.
     Load journal(ed) requests. These are requests were in the queuing pipeline
     when the process was terminated. put() is blocked until this has completed.
     """
     path = os.path.join(Pending.PENDING, self.stream)
     mkdir(path)
     log.info('Using: %s', path)
     for path in self._list():
         log.info('Restoring: %s', path)
         request = Pending._read(path)
         if not request:
             # read failed
             continue
         self._put(request, path)
     self.is_open = True
예제 #7
0
파일: plugin.py 프로젝트: pombredanne/gofer
 def load_all():
     """
     Load all plugins.
     :return: A list of loaded plugins.
     :rtype: list
     """
     loaded = []
     root = PluginDescriptor.ROOT
     mkdir(root)
     paths = [os.path.join(root, fn) for fn in os.listdir(root)]
     for path in sorted(paths):
         _, ext = os.path.splitext(path)
         if ext not in FileReader.EXTENSION:
             continue
         if os.path.isdir(path):
             continue
         plugin = PluginLoader.load(path)
         if plugin:
             loaded.append(plugin)
     return loaded
예제 #8
0
 def load_all():
     """
     Load all plugins.
     :return: A list of loaded plugins.
     :rtype: list
     """
     loaded = []
     root = PluginDescriptor.ROOT
     mkdir(root)
     paths = [os.path.join(root, fn) for fn in os.listdir(root)]
     for path in sorted(paths):
         _, ext = os.path.splitext(path)
         if ext not in FileReader.EXTENSION:
             continue
         if os.path.isdir(path):
             continue
         plugin = PluginLoader.load(path)
         if plugin:
             loaded.append(plugin)
     return loaded
예제 #9
0
 def test_exists(self, mkdirs):
     path = '/tmp/dir'
     exception = OSError()
     exception.errno = errno.EEXIST
     mkdirs.side_effect = exception
     mkdir(path)
예제 #10
0
 def test_make(self, mkdirs):
     path = '/tmp/dir'
     mkdir(path)
     mkdirs.assert_called_once_with(path)
예제 #11
0
 def test_exists(self, mkdirs):
     path = '/tmp/dir'
     exception = OSError()
     exception.errno = errno.EEXIST
     mkdirs.side_effect = exception
     mkdir(path)
예제 #12
0
 def test_make(self, mkdirs):
     path = '/tmp/dir'
     mkdir(path)
     mkdirs.assert_called_once_with(path)
예제 #13
0
파일: tracker.py 프로젝트: stbenjam/gofer
 def __init__(self):
     mkdir(Canceled.PATH)
     self.collection = set(os.listdir(Canceled.PATH))
예제 #14
0
파일: agent.py 프로젝트: jortel/gofer
[model]
queue=

"""

from gofer.common import mkdir

# logging
from gofer.agent import logutil

logutil.LogHandler.install()

# configuration
from gofer.agent.config import AgentConfig
mkdir(ROOT)
AgentConfig.PATH = os.path.join(ROOT, 'agent.conf')
if not os.path.exists(AgentConfig.PATH):
    with open(AgentConfig.PATH, 'w+') as fp:
        fp.write(AGENT_CONF)

# lock
from gofer.agent.main import AgentLock
AgentLock.PATH = os.path.join(ROOT, 'gofer.pid')

# pending queue
from gofer.rmi.store import Pending
Pending.PENDING = os.path.join(ROOT, 'messaging/pending')

# tracking
from gofer.rmi.tracker import Canceled
예제 #15
0
파일: server.py 프로젝트: swipswaps/gofer
from time import sleep
from optparse import OptionParser, Option
from hashlib import sha256
from logging import basicConfig
from threading import Thread
from datetime import datetime as dt

from gofer.common import mkdir
from gofer.rmi.dispatcher import *
from gofer.rmi. async import ReplyConsumer
from gofer.metrics import Timer
from gofer.proxy import Agent as RealAgent
from gofer.messaging import Queue, Authenticator, ValidationFailed

ROOT = os.path.expanduser('~/.gofer')
mkdir(ROOT)

basicConfig(filename=os.path.join(ROOT, 'server.log'))

log = getLogger(__name__)

# getLogger('gofer.adapter').setLevel(DEBUG)
# getLogger('gofer.messaging').setLevel(DEBUG)

USER = '******'


class TestFailed(Exception):
    pass