Skip to content

Commit

Permalink
migrate from rsync_options -> global_rsync and job specific rsync_opt…
Browse files Browse the repository at this point in the history
…ions; remove delete_options (this can and should now be done in the job specific rsync_optiosn key)
  • Loading branch information
txoof committed Aug 2, 2020
1 parent 7bb9214 commit 768a907
Showing 1 changed file with 42 additions and 19 deletions.
61 changes: 42 additions & 19 deletions automate_rsync.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 83,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -72,11 +72,14 @@
"\n",
"\n",
"EXPECTED_BASE_KEYS = {'rsync_bin': None,\n",
" 'rsync_options': '',\n",
" 'delete_options': '',\n",
" 'global_rsync': '',\n",
"# 'rsync_options': '',\n",
"# 'delete_options': '',\n",
" }\n",
"\n",
"EXPECTED_JOB_KEYS = {'direction': 'local-remote',\n",
" 'rsync_options': '',\n",
" 'ssh_options': '',\n",
" 'user': None,\n",
" 'remotehost': None,\n",
" 'sshkey': None,\n",
Expand All @@ -89,14 +92,16 @@
" 'kill': False,\n",
" }\n",
"\n",
"EXPECTED_SSH_KEYS = {'extrassh': ''}\n",
"EXPECTED_SSH_KEYS = {\n",
" 'extrassh': ''\n",
" }\n",
"\n",
"CONFIG_PATH = Path(f'~/.config/{DEVEL_NAME}.{APP_NAME}').expanduser().absolute()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 84,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -196,7 +201,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 85,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -212,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 86,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -237,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 87,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -255,7 +260,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 88,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -292,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 89,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -321,7 +326,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 90,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -372,8 +377,12 @@
" \n",
" # add the binary\n",
" rsync_command.append(rsync_bin.as_posix())\n",
" # add the options from the ini file\n",
" rsync_command.append(base_config['rsync_options'])\n",
" # add the global options from the ini file\n",
"# rsync_command.append(base_config['rsync_options'])\n",
" rsync_command.append(base_config['global_rsync'])\n",
" \n",
" # and any job specific rsync options\n",
" rsync_command.append(job['rsync_options'])\n",
" \n",
" # add additional options from the args\n",
" if dry_run:\n",
Expand All @@ -382,7 +391,7 @@
" if verbose:\n",
" rsync_command.append('-'+'v'*verbose)\n",
" \n",
" rsync_command.append(base_config['delete_options'])\n",
"# rsync_command.append(base_config['delete_options'])\n",
" \n",
" if job['sshkey']:\n",
"# ssh_command = f'ssh -o IdentitiesOnly=yes -i {job[\"sshkey\"]}'\n",
Expand Down Expand Up @@ -444,7 +453,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 91,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -484,7 +493,7 @@
},
{
"cell_type": "code",
"execution_count": 68,
"execution_count": 92,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -497,7 +506,7 @@
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": 93,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -693,9 +702,23 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": 80,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "KeyError",
"evalue": "'global_rsync'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-80-c58f9f3e1896>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'__main__'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mjob\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m<ipython-input-79-51e0ec3b5d57>\u001b[0m in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 78\u001b[0m rsync_commands[job] = build_rsync_command(name=job, job=parsed_jobs[job], base_config=base_config, ssh_opts=ssh_opts, \n\u001b[0;32m---> 79\u001b[0;31m tempdir=tempdir, dry_run=args.dry_run, verbose=verbose)\n\u001b[0m\u001b[1;32m 80\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-76-5e9af63bafd2>\u001b[0m in \u001b[0;36mbuild_rsync_command\u001b[0;34m(name, job, base_config, ssh_opts, tempdir, dry_run, verbose)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0;31m# add the global options from the ini file\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 49\u001b[0m \u001b[0;31m# rsync_command.append(base_config['rsync_options'])\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 50\u001b[0;31m \u001b[0mrsync_command\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbase_config\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'global_rsync'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 51\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 52\u001b[0m \u001b[0;31m# and any job specific rsync options\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyError\u001b[0m: 'global_rsync'"
]
}
],
"source": [
"if __name__ == '__main__':\n",
" job = main()"
Expand Down

0 comments on commit 768a907

Please sign in to comment.