-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathcommon.py
More file actions
43 lines (33 loc) · 1.09 KB
/
common.py
File metadata and controls
43 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import sys
import time
import unittest
_files = (
'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat',
'.api_started', 'unittest.lock'
)
def cleanup(home=None, files=_files):
"""Cleanup application files"""
if not home:
import state
home = state.appdata
for pfile in files:
try:
os.remove(os.path.join(home, pfile))
except OSError:
pass
def checkup():
"""Checkup files in the src dir"""
src_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir))
for f in _files:
if os.path.isfile(os.path.join(src_dir, f)):
return 'Found application file %s in src dir' % f
def skip_python3():
"""Raise unittest.SkipTest() if detected python3"""
if sys.hexversion >= 0x3000000:
raise unittest.SkipTest('Module is not ported to python3')
def put_signal_file(path, filename):
"""Creates file, presence of which is a signal about some event."""
with open(os.path.join(path, filename), 'wb') as outfile:
outfile.write(b'%i' % time.time())