Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CodiMD export script
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stgroup
misc
CodiMD export script
Commits
26abbead
Commit
26abbead
authored
2 years ago
by
Andreas Domanowski
Browse files
Options
Downloads
Patches
Plain Diff
Exit script if importing fails
parent
1f30c1cc
No related branches found
No related tags found
1 merge request
!1
Hedgedoc import
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
import_md/hedgedoc_import.py
+7
-2
7 additions, 2 deletions
import_md/hedgedoc_import.py
with
7 additions
and
2 deletions
import_md/hedgedoc_import.py
+
7
−
2
View file @
26abbead
...
...
@@ -17,7 +17,11 @@ def import_single_document(instance_url, hedgedoc_free_url, content, session_id)
req
=
urllib
.
request
.
Request
(
request_url
,
data
=
str
.
encode
(
content
),
method
=
'
POST
'
,
headers
=
headers
)
# unfortunately, no error is thrown if a document is not created when session cookie is invalid
# HTTP 409 is ignored for the sake of simplicity. Handled in import_into_hedgedoc(..)
# Not optimal, but nobody ain't got time for that
with
urllib
.
request
.
urlopen
(
req
)
as
response
:
if
response
.
url
==
instance_url
+
"
/
"
:
raise
SystemExit
(
"
Could not import document. Please check your HedgeDoc session cookie. Aborting...
"
)
return
response
.
url
...
...
@@ -75,8 +79,9 @@ def process_archive_export(archive_file, instance_url, lookup_map, session_id, u
try_generate_free_url_document
(
document_content
,
document_title
,
instance_url
,
lookup_map
,
session_id
,
urls_to_visit
)
else
:
print
(
f
"
According to your history, you did not visit
\"
{
document_title
}
.md
\"
in the CodiMD
"
"
instance recently. Migrating the document and generating a new, random URL/path for it
"
)
print
(
f
"
According to your history (or lack thereof) , you did not visit
\"
{
document_title
}
.md
\"
in the
"
f
"
CodiMD instance recently. Migrating the document and generating a new, random URL/path for it
"
)
# empty string implies HedgeDoc should create a new ID
generated_url
=
import_single_document
(
instance_url
,
""
,
document_content
,
session_id
)
print
(
f
"
New URL after document migration with new, random URL/subpath:
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment