Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
librestash
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nik | Klampfradler
librestash
Commits
af6cb9b7
Unverified
Commit
af6cb9b7
authored
6 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Explicitly flush session for new objects.
Autocommit was removed in SQLAlchemy 1.3.
parent
4d0d2d8a
No related branches found
No related tags found
No related merge requests found
Pipeline
#115
failed
6 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
librestash/lib/adaptors/gpx.py
+17
-0
17 additions, 0 deletions
librestash/lib/adaptors/gpx.py
with
17 additions
and
0 deletions
librestash/lib/adaptors/gpx.py
+
17
−
0
View file @
af6cb9b7
...
...
@@ -31,6 +31,8 @@ class GpxImporter(object):
if
not
waypoint
:
logger
.
info
(
'
Creating new waypoint %s
'
%
code
)
waypoint
=
Waypoint
(
code
=
code
)
session
.
add
(
waypoint
)
session
.
flush
()
# Update waypoint data
logger
.
info
(
'
Updating waypoint %s
'
%
code
)
...
...
@@ -50,6 +52,8 @@ class GpxImporter(object):
else
:
logger
.
info
(
'
Creating new cache listing for %s
'
%
code
)
listing
=
Listing
(
master_waypoint
=
waypoint
,
waypoints
=
[
waypoint
])
session
.
add
(
listing
)
session
.
flush
()
# Update listing data
logger
.
info
(
'
Updating listing for %s
'
%
code
)
...
...
@@ -70,6 +74,8 @@ class GpxImporter(object):
owner_account
=
GeocacherAccount
(
name
=
owner_name
,
platform_prefix
=
listing
.
platform_prefix
)
Geocacher
(
accounts
=
[
owner_account
],
master_account
=
owner_account
)
session
.
add
(
owner_account
)
session
.
flush
()
listing
.
owner_account
=
owner_account
# Find or create geocache parent
...
...
@@ -85,12 +91,16 @@ class GpxImporter(object):
if
not
other_waypoint
:
logger
.
info
(
'
Creating new waypoint for %s
'
%
other_code
)
other_waypoint
=
Waypoint
(
code
=
other_code
)
session
.
add
(
other_waypoint
)
session
.
flush
()
if
other_waypoint
.
listing
:
other_listing
=
other_waypoint
.
listing
else
:
logger
.
info
(
'
Creating listing for %s
'
%
other_code
)
other_listing
=
Listing
(
master_waypoint
=
other_waypoint
,
waypoints
=
[
other_waypoint
])
session
.
add
(
other_listing
)
session
.
flush
()
if
other_listing
.
geocache
:
listing
.
geocache
=
other_listing
.
geocache
else
:
...
...
@@ -115,6 +125,8 @@ class GpxImporter(object):
logger
.
info
(
'
Creating finder %s
'
%
finder_name
)
finder_account
=
GeocacherAccount
(
name
=
finder_name
,
platform_prefix
=
listing
.
platform_prefix
)
Geocacher
(
accounts
=
[
finder_account
],
master_account
=
finder_account
)
session
.
add
(
finder_account
)
session
.
flush
()
# Get log data
date
=
dateutil
.
parser
.
parse
(
xml_get_text
(
log_node
,
'
groundspeak:date
'
))
...
...
@@ -128,6 +140,8 @@ class GpxImporter(object):
if
not
log
:
log
=
Log
(
date
=
date
,
type
=
type_
,
geocacher_account
=
finder_account
,
listing
=
listing
)
session
.
add
(
log
)
session
.
flush
()
log
.
text
=
text
elif
waypoint
.
type
.
startswith
(
'
Waypoint|
'
):
# This is a sub-waypoint
...
...
@@ -152,6 +166,8 @@ class GpxImporter(object):
if
not
parent_listing
:
parent_listing
=
Listing
(
master_waypoint
=
parent_waypoint
,
waypoints
=
[
parent_waypoint
])
session
.
add
(
parent_listing
)
session
.
flush
()
# Add waypoint
logger
.
info
(
'
Linking %s to %s
'
%
(
waypoint
.
code
,
parent_code
))
...
...
@@ -159,6 +175,7 @@ class GpxImporter(object):
# Add waypoint and all related objects to session
session
.
add
(
waypoint
)
session
.
flush
()
# Save
session
.
commit
()
...
...
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