Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/build/sage_bootstrap/fileserver.py
4052 views
1
# -*- coding: utf-8 -*-
2
"""
3
Interface to the Sage fileserver
4
"""
5
6
# ****************************************************************************
7
# Copyright (C) 2016 Volker Braun <[email protected]>
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 2 of the License, or
12
# (at your option) any later version.
13
# https://www.gnu.org/licenses/
14
# ****************************************************************************
15
16
import os
17
import subprocess
18
19
20
class FileServer(object):
21
22
def __init__(self):
23
self.user = 'sagemath'
24
self.hostname = 'fileserver.sagemath.org'
25
26
def upstream_directory(self, package):
27
"""
28
Return the directory where the tarball resides on the server
29
"""
30
return os.path.join(
31
'/', 'data', 'files', 'spkg', 'upstream', package.name,
32
)
33
34
def upload(self, package):
35
"""
36
Upload the current tarball of package
37
"""
38
if not package.tarball.is_distributable():
39
raise ValueError('Tarball of {} is marked as not distributable'.format(package))
40
subprocess.check_call([
41
'ssh', '[email protected]',
42
'mkdir -p {0} && touch {0}/index.html'.format(self.upstream_directory(package))
43
])
44
subprocess.check_call([
45
'rsync', '-av', '--checksum', '-e', 'ssh -l sagemath',
46
package.tarball.upstream_fqn,
47
'fileserver.sagemath.org:{0}'.format(self.upstream_directory(package))
48
])
49
50
def publish(self):
51
"""
52
Publish the files
53
"""
54
subprocess.check_call([
55
'ssh', '[email protected]', './publish-files.sh'
56
])
57
58