コード例 #1
0
ファイル: flowapi.py プロジェクト: infoabcd/inti
def get_post_by_board(board):
    board_cache = DeadSimpleKV(BOARD_CACHE_FILE, flush_on_exit=False)
    board_cache.refresh()
    posts = board_cache.get(board)
    if posts is None:
        posts = ''
    else:
        posts = ','.join(posts)
    return Response(posts)
コード例 #2
0
ファイル: flowapi.py プロジェクト: infoabcd/inti
def get_post_by_board_with_offset(board, offset):
    offset = int(offset)
    OFFSET_COUNT = 10
    board_cache = DeadSimpleKV(BOARD_CACHE_FILE, flush_on_exit=False)
    board_cache.refresh()
    posts = board_cache.get(board)
    if posts is None:
        posts = ''
    else:
        posts.reverse()
        posts = ','.join(posts[offset:offset + OFFSET_COUNT])
    return Response(posts)
コード例 #3
0
ファイル: flowapi.py プロジェクト: infoabcd/inti
def remove_from_cache(board, name):
    board_cache = DeadSimpleKV(BOARD_CACHE_FILE, flush_on_exit=False)
    board_cache.refresh()
    posts = board_cache.get(board)
    try:
        posts.remove(name)
    except ValueError:
        pass
    board_cache.put(board, posts)
    return Response('success')
コード例 #4
0
ファイル: flowapi.py プロジェクト: infoabcd/inti
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
"""

flask_blueprint = Blueprint('circles', __name__)

root = os.path.dirname(os.path.realpath(__file__))

with open(os.path.dirname(os.path.realpath(__file__)) + '/info.json',
          'r') as info_file:
    data = info_file.read().strip()
    version = json.loads(data)['version']

BOARD_CACHE_FILE = identifyhome.identify_home() + '/board-index.cache.json'

read_only_cache = DeadSimpleKV(BOARD_CACHE_FILE,
                               flush_on_exit=False,
                               refresh_seconds=30)


@flask_blueprint.route('/board/<path:path>', endpoint='circlesstatic')
def load_mail(path):
    return send_from_directory(root + '/web/', path)


@flask_blueprint.route('/board/', endpoint='circlesindex')
def load_mail_index():
    return send_from_directory(root + '/web/', 'index.html')


@flask_blueprint.route('/circles/getpostsbyboard/<board>')
def get_post_by_board(board):
コード例 #5
0
ファイル: test_setupkvvars.py プロジェクト: infoabcd/inti
    def test_set_var_values(self):

        kv = DeadSimpleKV()
        setupkvvars.setup_kv(kv)
        self.assertEqual(kv.get('blockQueue'), {})
        self.assertFalse(kv.get('shutdown'))
        self.assertEqual(kv.get('onlinePeers'), [])
        self.assertEqual(kv.get('offlinePeers'), [])
        self.assertEqual(kv.get('peerProfiles'), [])
        self.assertEqual(kv.get('connectTimes'), {})
        self.assertEqual(kv.get('currentDownloading'), [])
        self.assertEqual(kv.get('announceCache'), {})
        self.assertEqual(kv.get('newPeers'), [])
        self.assertEqual(kv.get('dbTimestamps'), {})
        self.assertEqual(kv.get('blocksToUpload'), [])
        self.assertEqual(kv.get('cooldownPeer'), {})
        self.assertEqual(kv.get('generating_blocks'), [])
        self.assertEqual(kv.get('lastNodeSeen'), None)
        self.assertAlmostEqual(math.floor(kv.get('startTime')),
                               math.floor(time.time()),
                               places=0)
        self.assertTrue(kv.get('isOnline'))