Skip to content

Instantly share code, notes, and snippets.

View awead's full-sized avatar
🏠
Working from home

Adam Wead awead

🏠
Working from home
View GitHub Profile
DEBUG output created by Wget 1.14 on linux-gnu.
URI encoding = bUTF-8b
Converted file name 'd0e3a775-f4f5-4421-8128-60474fa2e217' (UTF-8) -> 'd0e3a775-f4f5-4421-8128-60474fa2e217' (UTF-8)
Converted file name 'd0e3a775-f4f5-4421-8128-60474fa2e217' (UTF-8) -> 'd0e3a775-f4f5-4421-8128-60474fa2e217' (UTF-8)
--2018-08-16 12:07:57-- http://fedoraAdmin:*password*@dce-fedora.vmhost.psu.edu:8080/SStestFedora/rest/prod/ws/t7/4c/r7/wst74cr74c/files/d0e3a775-f4f5-4421-8128-60474fa2e217
Resolving dce-fedora.vmhost.psu.edu (dce-fedora.vmhost.psu.edu)... 128.118.137.162
Caching dce-fedora.vmhost.psu.edu => 128.118.137.162
Connecting to dce-fedora.vmhost.psu.edu (dce-fedora.vmhost.psu.edu)|128.118.137.162|:8080... connected.
Created socket 3.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to dce-fedora.vmhost.psu.edu port 8080 (#0)
* Trying 128.118.137.162...
* Connected to dce-fedora.vmhost.psu.edu (128.118.137.162) port 8080 (#0)
* Server auth using Basic with user 'fedoraAdmin'
> HEAD /SStestFedora/rest/prod/ws/t7/4c/r7/wst74cr74c/files/d0e3a775-f4f5-4421-8128-60474fa2e217 HTTP/1.1
> Authorization: Basic ZmVkb3JhQWRtaW46ZmVkb3JhNGVBZG1pbg==
> User-Agent: curl/7.29.0
> Host: dce-fedora.vmhost.psu.edu:8080
@awead
awead / gist:2ff3c8686b22edb97c059ab24c166bab
Created August 14, 2018 13:49
Stack trace from Fedora external files migration
[deploy@dce-fedora current]$ RAILS_ENV='production' bundle exec rake scholarsphere:internal_to_external_files
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in <main> at /opt/heracles/deploy/scholarsphere/releases/20180720180339/config/environments/production.rb:51)
This task will create a new version of all the works.
The process will place the content in the /opt/heracles/binaries directory.
Are you sure you want to do this? (y/n)
y
rake aborted!
Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8
/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/object/json.rb:34:in `encode'
/opt/heracles/depl
SSHKit::Runner::ExecuteError: Exception while executing as deploy@choweb1qa.vmhost.psu.edu: Exception while executing as deploy@choweb1qa.vmhost.psu.edu: rake exit status: 1
rake stdout: == 20170814150454 EnableUuidExtension: migrating ==============================
-- enable_extension("uuid-ossp")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedFile: ERROR: could not open extension control file "/opt/rh/rh-postgresql95/root/usr/share/pgsql/extension/uuid-ossp.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
<http://localhost:8986/rest/dev/07/b5/2b/84/07b52b84-ede0-4b0d-900c-360c9ca9635b>
rdf:type fedora:Container ;
rdf:type ns004:Work ;
rdf:type fedora:Resource ;
rdf:type ns005:Object ;
fedora:lastModifiedBy "bypassAdmin"^^<http://www.w3.org/2001/XMLSchema#string> ;
iana:last <http://localhost:8986/rest/dev/07/b5/2b/84/07b52b84-ede0-4b0d-900c-360c9ca9635b/list_source#g70338943490600> ;
ns002:hasModel "Valkyrie::Persistence::ActiveFedora::ORM::Resource"^^<http://www.w3.org/2001/XMLSchema#string> ;
ns003:internal_resource "Book"^^<http://www.w3.org/2001/XMLSchema#string> ;
fedora:createdBy "bypassAdmin"^^<http://www.w3.org/2001/XMLSchema#string> ;
@awead
awead / title_order.rb
Created June 7, 2017 15:31
Fixing mis-ordered fifles
# Reports on and fixes mis-ordered titles.
# To run, download the raw output of the array of works with multiple titles. Open the file
# in a text editor and add "@@titles = " to the beginning of the line to set the array as
# class variable. Save the file as titles.rb and upload it to the temp directory of the server.
#
# From the Rails console, copy and paste in the code below. Run the report and fix the works.
# A possible sequence would be:
#
# > report = TitleOrder.new
# > report.misordered_titles
@awead
awead / digest_check.rb
Created June 7, 2017 13:36
Version checksum report
# Checks the shasum of each version and current content in old production
# and compares it to those in new production.
#
# To run the report, go to the Rails console and copy-in the two classes in the file.
# Then run:
#
# > report = ChecksumReport.new
#
# The report is an array of hashes, each of which looks like:
#
irb(main):009:0> gf = GenericWork.new(title: ["Trying out steps"])
=> #<GenericWork id: nil, head: [], tail: [], depositor: nil, title: ["Trying out steps"], date_uploaded: nil, date_modified: nil, state: nil, owner: nil, label: nil, relative_path: nil, import_url: nil, part_of: [], resource_type: [], creator: [], contributor: [], description: [], keyword: [], rights: [], rights_statement: [], publisher: [], date_created: [], subject: [], language: [], identifier: [], based_near: [], related_url: [], bibliographic_citation: [], source: [], proxy_depositor: nil, on_behalf_of: nil, arkivo_checksum: nil, upload_set: nil, access_control_id: nil, representative_id: nil, thumbnail_id: nil, admin_set_id: nil, embargo_id: nil, lease_id: nil>
irb(main):010:0> gf.apply_depositor_metadata("awead")
=> true
irb(main):011:0> new_id = gf.assign_id
=> "83b591b306"
irb(main):012:0> ldp_source = ActiveFedora::LdpResource.new(ActiveFedora.fedora.connection, gf.class.id_to_uri(new_id), nil)
=> #<ActiveFedora::LdpResource:0x007fa
# List of fileset ids in the last 60 days:
fs_ids = ActiveFedora::SolrService.query("has_model_ssim:FileSet", rows: 100000, fq: "date_uploaded_dtsi:[NOW-60DAY/DAY TO NOW]", fl: ["id"]).map(&:id)
# Ids of orphaned file sets from the list created above:
fs_ids.map { |id| id unless ActiveFedora::SolrService.query("member_ids_ssim:#{id}").present? }.compact
=> ["0k643b017c"]
# Check timestamp differences between system create date and date uploaded
# Returns an array of FileSet labels where the set's date differences are 5 seconds or less and the set has no parent
@awead
awead / gist:53989e9d4bf7ebb338378a7b3991f52f
Created November 8, 2016 15:25
PUTing big files into Fedora
# NOTE: using -k for the "insecure" option when connecting to https
# Test connection
curl -k -u username:password -X GET https://fedora.server/rest
# Upload a bigfile
curl -k -u username:password -X PUT --data-binary @/path/to/file https://fedora.server/rest/bigfile
# Delete it
curl -k -u username:password -X DELETE https://fedora.server/rest/bigfile