Skip to content

Commit 5c809ec

Browse files
authored
Drop logic for non-installed use case (#1311)
1 parent c87fea7 commit 5c809ec

File tree

4 files changed

+14
-64
lines changed

4 files changed

+14
-64
lines changed

cms/conf.py

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -162,37 +162,14 @@ def __init__(self):
162162
self.max_jobs_per_user = 10
163163
self.pdf_printing_allowed = False
164164

165-
# Installed or from source?
166-
# We declare we are running from installed if the program was
167-
# NOT invoked through some python flavor, and the file is in
168-
# the prefix (or real_prefix to accommodate virtualenvs).
169-
bin_path = os.path.join(os.getcwd(), sys.argv[0])
170-
bin_name = os.path.basename(bin_path)
171-
bin_is_python = bin_name in ["ipython", "python", "python3"]
172-
bin_in_installed_path = bin_path.startswith(sys.prefix) or (
173-
hasattr(sys, 'real_prefix')
174-
and bin_path.startswith(sys.real_prefix))
175-
self.installed = bin_in_installed_path and not bin_is_python
176-
177-
if self.installed:
178-
self.log_dir = os.path.join("/", "var", "local", "log", "cms")
179-
self.cache_dir = os.path.join("/", "var", "local", "cache", "cms")
180-
self.data_dir = os.path.join("/", "var", "local", "lib", "cms")
181-
self.run_dir = os.path.join("/", "var", "local", "run", "cms")
182-
paths = [os.path.join("/", "usr", "local", "etc", "cms.conf"),
183-
os.path.join("/", "etc", "cms.conf")]
184-
else:
185-
self.log_dir = "log"
186-
self.cache_dir = "cache"
187-
self.data_dir = "lib"
188-
self.run_dir = "run"
189-
paths = [os.path.join(".", "config", "cms.conf")]
190-
if '__file__' in globals():
191-
paths += [os.path.abspath(os.path.join(
192-
os.path.dirname(__file__),
193-
'..', 'config', 'cms.conf'))]
194-
paths += [os.path.join("/", "usr", "local", "etc", "cms.conf"),
195-
os.path.join("/", "etc", "cms.conf")]
165+
self.log_dir = os.path.join("/", "var", "local", "log", "cms")
166+
self.cache_dir = os.path.join("/", "var", "local", "cache", "cms")
167+
self.data_dir = os.path.join("/", "var", "local", "lib", "cms")
168+
self.run_dir = os.path.join("/", "var", "local", "run", "cms")
169+
paths = [
170+
os.path.join("/", "usr", "local", "etc", "cms.conf"),
171+
os.path.join("/", "etc", "cms.conf"),
172+
]
196173

197174
# Allow user to override config file path using environment
198175
# variable 'CMS_CONFIG'.

cms/service/ResourceService.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,6 @@ def _restart_services(self):
247247
logger.info("Restarting (%s, %s)...",
248248
service.name, service.shard)
249249
command = os.path.join(BIN_PATH, "cms%s" % service.name)
250-
if not config.installed:
251-
command = os.path.join(
252-
".",
253-
"scripts",
254-
"cms%s" % service.name)
255250
args = [command, "%d" % service.shard]
256251
if self.contest_id is not None:
257252
args += ["-c", str(self.contest_id)]

cmscontrib/loaders/polygon.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ def get_task(self, get_statement=True):
185185
os.path.dirname(checker_src), "checker")
186186
testlib_path = "/usr/local/include/cms"
187187
testlib_include = os.path.join(testlib_path, "testlib.h")
188-
if not config.installed:
189-
testlib_path = os.path.join(os.path.dirname(__file__),
190-
"polygon")
191188
code = subprocess.call(["g++", "-x", "c++", "-O2", "-static",
192189
"-DCMS", "-I", testlib_path,
193190
"-include", testlib_include,

cmsranking/Config.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,13 @@ def __init__(self):
5757
# Buffers
5858
self.buffer_size = 100 # Needs to be strictly positive.
5959

60-
# File system.
61-
# TODO: move to cmscommon as it is used both here and in cms/conf.py
62-
bin_path = os.path.join(os.getcwd(), sys.argv[0])
63-
bin_name = os.path.basename(bin_path)
64-
bin_is_python = bin_name in ["ipython", "python", "python3"]
65-
bin_in_installed_path = bin_path.startswith(sys.prefix) or (
66-
hasattr(sys, 'real_prefix')
67-
and bin_path.startswith(sys.real_prefix))
68-
self.installed = bin_in_installed_path and not bin_is_python
69-
7060
self.web_dir = pkg_resources.resource_filename("cmsranking", "static")
71-
if self.installed:
72-
self.log_dir = os.path.join("/", "var", "local", "log",
73-
"cms", "ranking")
74-
self.lib_dir = os.path.join("/", "var", "local", "lib",
75-
"cms", "ranking")
76-
self.conf_paths = [os.path.join("/", "usr", "local", "etc",
77-
"cms.ranking.conf"),
78-
os.path.join("/", "etc", "cms.ranking.conf")]
79-
else:
80-
self.log_dir = os.path.join("log", "ranking")
81-
self.lib_dir = os.path.join("lib", "ranking")
82-
self.conf_paths = [os.path.join(".", "config", "cms.ranking.conf"),
83-
os.path.join("/", "usr", "local", "etc",
84-
"cms.ranking.conf"),
85-
os.path.join("/", "etc", "cms.ranking.conf")]
61+
self.log_dir = os.path.join("/", "var", "local", "log", "cms", "ranking")
62+
self.lib_dir = os.path.join("/", "var", "local", "lib", "cms", "ranking")
63+
self.conf_paths = [
64+
os.path.join("/", "usr", "local", "etc", "cms.ranking.conf"),
65+
os.path.join("/", "etc", "cms.ranking.conf"),
66+
]
8667

8768
# Allow users to override config file path using environment
8869
# variable 'CMS_RANKING_CONFIG'.

0 commit comments

Comments
 (0)