File: constants.py

package info (click to toggle)
psychopy 2020.2.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 44,056 kB
  • sloc: python: 119,649; javascript: 3,022; makefile: 148; sh: 125; xml: 9
file content (64 lines) | stat: -rw-r--r-- 2,155 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# instead of import *, use this (+ PSYCHOPY_USERAGENT if you need that)
# (NOT_STARTED, STARTED, PLAYING, PAUSED, STOPPED, FINISHED, PRESSED,
#  RELEASED, FOREVER)

from __future__ import absolute_import, print_function

import sys, os, copy
from os.path import abspath, join

if sys.version_info.major >= 3:
    PY3 = True
else:
    PY3 = False

NOT_STARTED = 0
PLAYING = 1
STARTED = PLAYING
PAUSED = 2
STOPPED = -1
FINISHED = STOPPED
SKIP = -2
STOPPING = -3

# for button box:
PRESSED = 1
RELEASED = -1

# while t < FOREVER ... -- in scripts generated by Builder
FOREVER = 1000000000  # seconds

# USERAGENT is for consistent http-related self-identification across an app.
# It shows up in server logs on the receiving end. Currently the value (and
# its use from psychopy) is arbitrary and optional. Having it standardized
# and fixed will also help people who develop their own http-log analysis
# tools for use with contrib.http.upload()
PSYCHOPY_USERAGENT = ("PsychoPy: open-source Psychology & Neuroscience tools; "
                      "www.psychopy.org")


# find a copy of git if possible to do push/pull as needed
# the pure-python dulwich lib can do most things but merged push/pull
# isn't currently possible (e.g. pull overwrites any local commits!)
# see https://github.com/dulwich/dulwich/issues/666
ENVIRON = copy.copy(os.environ)
gitExe = None
if sys.platform == 'darwin':
    _gitStandalonePath = abspath(join(sys.executable, '..', '..',
                                      'Resources', 'git-core'))
    if os.path.exists(_gitStandalonePath):
        ENVIRON["PATH"] = "{}:".format(_gitStandalonePath) + ENVIRON["PATH"]
        gitExe = join(_gitStandalonePath, 'git')

elif sys.platform == 'win32':
    _gitStandalonePath = abspath(join(sys.executable, '..', 'MinGit', 'cmd'))
    if os.path.exists(_gitStandalonePath):
        ENVIRON["PATH"] = "{};".format(_gitStandalonePath) + ENVIRON["PATH"]
        os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = _gitStandalonePath
        gitExe = join(_gitStandalonePath, 'git.exe')

if gitExe:
    os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = gitExe