Fixed atom exporting, and a few other things
This commit is contained in:
parent
ee870e2d12
commit
8282b3211a
5 changed files with 53 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
||||||
import click
|
import click
|
||||||
from project.export import exports
|
from project.export import exports
|
||||||
|
from project.utils import repos
|
||||||
|
|
||||||
|
|
||||||
@click.command('export')
|
@click.command('export')
|
||||||
|
@ -13,6 +14,7 @@ def cli(sections):
|
||||||
if func.__name__ in sections:
|
if func.__name__ in sections:
|
||||||
functions.append(func)
|
functions.append(func)
|
||||||
for func in functions:
|
for func in functions:
|
||||||
|
repos.go_to_data() # Reset data directory
|
||||||
func()
|
func()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,32 @@
|
||||||
|
import os, shutil
|
||||||
|
from yaml import load, dump
|
||||||
|
from project.utils import shell, constants
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader, CDumper as Dumper
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader, Dumper
|
||||||
|
|
||||||
|
|
||||||
def atom():
|
def atom():
|
||||||
print("atom")
|
out, error = shell.call('which apm')
|
||||||
|
if not out or error:
|
||||||
|
print("You don't seem to have atom installed.")
|
||||||
|
return True
|
||||||
|
os.chdir('atom')
|
||||||
|
packages_themes = []
|
||||||
|
with open('packages.yml') as pt_file:
|
||||||
|
packages_themes = load(pt_file, Loader=Loader) or {}
|
||||||
|
for package in packages_themes:
|
||||||
|
exit_code = os.system('apm install {}'.format(package))
|
||||||
|
if exit_code != 0:
|
||||||
|
print("Error installing {}".format(package), exit_code)
|
||||||
|
return True
|
||||||
|
|
||||||
|
shutil.copy2(
|
||||||
|
os.path.join(constants.PUBLIC_DATA_DIR, 'atom', 'keymap.cson'),
|
||||||
|
os.path.expanduser("~/.atom/keymap.cson")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def thing():
|
def thing():
|
||||||
|
|
|
@ -3,8 +3,8 @@ from project.utils import config, repos
|
||||||
|
|
||||||
|
|
||||||
@click.command('sync')
|
@click.command('sync')
|
||||||
@click.option('--private', default=False)
|
@click.option('--private/--no-private', default=False, required=False)
|
||||||
@click.option('--clean', default=False)
|
@click.option('--clean/--no-clean', default=False, required=False)
|
||||||
def cli(private, clean):
|
def cli(private, clean):
|
||||||
if clean:
|
if clean:
|
||||||
print("Cleaning")
|
print("Cleaning")
|
||||||
|
@ -20,4 +20,4 @@ def cli(private, clean):
|
||||||
print("private repo not set")
|
print("private repo not set")
|
||||||
return 1
|
return 1
|
||||||
error = repos.clone_private_data()
|
error = repos.clone_private_data()
|
||||||
return int(error)
|
return 1 if error else 0
|
||||||
|
|
|
@ -12,3 +12,5 @@ REQUIRED_KEYS = ['public_repo']
|
||||||
# Data Directories
|
# Data Directories
|
||||||
PRIVATE_DATA_DIR = os.path.join(DATA_DIR, 'private_data')
|
PRIVATE_DATA_DIR = os.path.join(DATA_DIR, 'private_data')
|
||||||
PUBLIC_DATA_DIR = os.path.join(DATA_DIR, 'public_data')
|
PUBLIC_DATA_DIR = os.path.join(DATA_DIR, 'public_data')
|
||||||
|
|
||||||
|
ALL_DATA_DIR = os.path.join(DATA_DIR, 'all_data')
|
||||||
|
|
|
@ -5,47 +5,50 @@ from . import config, constants, shell
|
||||||
|
|
||||||
def clone_public_data():
|
def clone_public_data():
|
||||||
if os.path.isdir(constants.PUBLIC_DATA_DIR):
|
if os.path.isdir(constants.PUBLIC_DATA_DIR):
|
||||||
|
print("Updating public...")
|
||||||
initial = os.getcwd()
|
initial = os.getcwd()
|
||||||
go_to_data()
|
go_to_data()
|
||||||
out, error = shell.call("git pull")
|
out, error = shell.call("git pull")
|
||||||
os.chdir(initial)
|
os.chdir(initial)
|
||||||
if error:
|
print(out)
|
||||||
print("Error:", out)
|
else:
|
||||||
return error
|
print("Downloading public data...")
|
||||||
|
out, error = shell.call(
|
||||||
out, error = shell.call(
|
"git clone -b master --single-branch {} {}".format(
|
||||||
"git clone -b master --single-branch {} {}".format(
|
config.get('public_repo'),
|
||||||
config.get('public_repo'),
|
constants.PUBLIC_DATA_DIR
|
||||||
constants.PUBLIC_DATA_DIR
|
)
|
||||||
)
|
)
|
||||||
|
print(out)
|
||||||
|
copy_tree(
|
||||||
|
constants.PUBLIC_DATA_DIR,
|
||||||
|
constants.ALL_DATA_DIR
|
||||||
)
|
)
|
||||||
return error
|
|
||||||
|
|
||||||
|
|
||||||
def clone_private_data():
|
def clone_private_data():
|
||||||
if os.path.isdir(constants.PRIVATE_DATA_DIR):
|
if os.path.isdir(constants.PRIVATE_DATA_DIR):
|
||||||
|
print("Updating private data...")
|
||||||
initial = os.getcwd()
|
initial = os.getcwd()
|
||||||
os.chdir(constants.PRIVATE_DATA_DIR)
|
os.chdir(constants.PRIVATE_DATA_DIR)
|
||||||
out, error = shell.call("git pull")
|
out, error = shell.call("git pull")
|
||||||
os.chdir(initial)
|
os.chdir(initial)
|
||||||
if error:
|
print(out)
|
||||||
print("Error:", out)
|
|
||||||
return error
|
return error
|
||||||
else:
|
else:
|
||||||
|
print("Downloading private data...")
|
||||||
out, error = shell.call(
|
out, error = shell.call(
|
||||||
"git clone -b master --single-branch {} {}".format(
|
"git clone -b master --single-branch {} {}".format(
|
||||||
config.get('private_repo'),
|
config.get('private_repo'),
|
||||||
constants.PRIVATE_DATA_DIR
|
constants.PRIVATE_DATA_DIR
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if error:
|
print(out)
|
||||||
return error
|
|
||||||
|
|
||||||
copy_tree(
|
copy_tree(
|
||||||
constants.PRIVATE_DATA_DIR,
|
constants.PRIVATE_DATA_DIR,
|
||||||
constants.PUBLIC_DATA_DIR
|
constants.ALL_DATA_DIR
|
||||||
)
|
)
|
||||||
return error
|
|
||||||
|
|
||||||
|
|
||||||
def has_data(data):
|
def has_data(data):
|
||||||
|
|
Reference in a new issue