Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/scripts/ensure_file_exists.py
Views: 687
#!/usr/bin/python1###############################################################################2#3# CoCalc: Collaborative Calculation4#5# Copyright (C) 2016, Sagemath Inc.6#7# This program is free software: you can redistribute it and/or modify8# it under the terms of the GNU General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# This program is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU General Public License for more details.16#17# You should have received a copy of the GNU General Public License18# along with this program. If not, see <http://www.gnu.org/licenses/>.19#20###############################################################################2122import os, shutil, sys2324if len(sys.argv) != 3:25sys.stderr.write(26"%s src target\n\n if target doesn't exist, copy src to it and chown target to have permissions of contain dir\n\n"27% sys.argv[0])28sys.exit(1)2930_, src, target = sys.argv3132if not os.path.exists(target):33shutil.copyfile(src, target)34s = os.stat(os.path.split(target)[0])35os.chown(target, s.st_uid, s.st_gid)363738