Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main dev #3

Merged
merged 6 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 38 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,102 @@
## Post XML files to a server port
# XML_postToREST

XML_postToREST is a Python program for posting DOIs metadata in XML format to DataCite REST API

<br/>

### Step 1
## Getting Started

`xml_post_parser.py` is the program you will call to do the task

It will call two python classes:
* `class_xml_encode.py`: encode XML files to JSON envelope

* `class_json_post.py`: post JSON envelopes to server port


<br/>

Check the `"xml_post_parser_config.json"` file for the configurations of the codes
## Usage

Check the configuration file `xml_post_parser_config.json` and start configure your program:

<br/>


**Important fields**

`"server_port"`:
```
"server_port":

the location you want to post your files to

`"bearer_auth_key"`:
"bearer_auth_key":

your Bearer Auth key to access DataCite REST API

`"prefix"`:
"prefix":

namespace of the DOIs you are using

`"schema_url"`:
"schema_url":

schema for the DOIs
```

<br/>

**Folder names**

`"xml_folder"`:
```
"xml_folder":

the directory for your input XML files

`"json_folder"`:
"json_folder":

the directory for your JSON envelopes to be stored at

`"processed_xml_folder"`:
"processed_xml_folder":

the directory for your processed XML files

`"posted_json_folder"`:
"posted_json_folder":

the directory for your successfully posted JSON envelopes

`"post_failed_folder"`:
"post_failed_folder":

the directory for your JSON envelopes that failed to post

```
<br/>
----------------------------------------

### Step 2

<br/>

From the config file, use the value of `"xml_folder"` as the name to create a folder in the same directory
Then from the config file, use the value of `"xml_folder"` as the name to create a folder in the same directory

Store your xml files to be posted to the folder

<br/>

### Step 3

<br/>

Run the python script
Last, run `xml_post_parser.py`

```python
``` python
python xml_post_parser.py
```

The XML files will now begin to be encoded into JSON files and then posted to the server port
XML files will begin to be encoded into JSON files and then posted to the server port

**Successfully posted** files will be stored at `"posted_json_folder"`

**Failed files** will be stored at `"post_failed_folder"`

<br/>

## Additional files
## Additional file for testing

<br/>

`clear_folders.py`:
`tests/test_server.py`:

empty all folders after posting (except `"xml_src"`)

<br/>

`test_server.py`:

construct a dummy server using port 5000 in localhost

you can view the posted json files on http://localhost:5000/data

run `test_server.py` in one terminal and `xml_post_parser.py` in another
construct a dummy server at http://localhost:5000

you can post data to http://localhost:5000 and view the posted data on http://localhost:5000/data

***Remember to change "server_port" in the config file to http://localhost:5000/***

File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions clear_folders.py

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions xml_post_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import xml_encode
import json_post
import class_xml_encode as xml_encode
import class_json_post as json_post
from os import listdir
from os.path import isfile, join
import os
Expand Down