Comments (3)
I've been playing with some code to try and implement this in a transparent way, for the code base
import mmap
from google.cloud import storage
def slice_big(file, slices, total_size, filename):
storage_client = storage.Client()
bucket = storage_client.bucket('somebbucket')
if int(slices) < 1:
raise Exception('Need at least 1 slice')
number_of_pages = int(total_size / int(slices) / mmap.PAGESIZE)
slice_size = number_of_pages * mmap.PAGESIZE
for i, seek in enumerate(range(0, total_size, slice_size)):
length = slice_size
if seek+slice_size > total_size:
# No trying to read past end of filedescriptor
length = total_size - seek
print(f'sending slice {i} from bytes {seek} to {seek+length}')
m = mmap.mmap(
fd.fileno(), length=length, offset=seek, access=mmap.ACCESS_READ)
blob = bucket.blob('large_split/'+filename+f'_{i}')
blob.upload_from_file(m)
slice_big(open('/dev/loop0', 'rb'), 12, 1048576000, 'big')
from giftstick.
This seem to work.
But I can't use that mmap method when reading from dcfldd
from giftstick.
We can also skip already present slices
import mmap
from google.cloud import storage
def slice_big(fd, slices, total_size, filename, skip_exist=False):
storage_client = storage.Client()
bucket = storage_client.bucket('somebbucket')
if int(slices) < 1:
raise Exception('Need at least 1 slice')
# mmap requires that the an offset is a multiple of mmap.PAGESIZE
# so we can't just equally divide the total size in the specified number of
# slices.
number_of_pages = int(total_size / int(slices) / mmap.PAGESIZE)
slice_size = number_of_pages * mmap.PAGESIZE
for i, seek in enumerate(range(0, total_size, slice_size)):
blob_path = 'large_split/'+filename+f'_{i}'
blob = bucket.blob(blob_path)
if skip_exist and blob.exists():
print(f'{blob_path} already exists, skipping')
continue
length = slice_size
if seek+slice_size > total_size:
length = total_size - seek
print(f'sending slice {i} from bytes {seek} to {seek+length}')
m = mmap.mmap(
fd.fileno(), length=length, offset=seek, access=mmap.ACCESS_READ)
blob.upload_from_file(m)
slice_big(open('/dev/loop0', 'rb'), 12, 1048576000, 'biggy', skip_exist=True)
from giftstick.
Related Issues (20)
- Make a UX interface object
- Consider collecting extended attributes with logical acquisition
- Collect more system information HOT 2
- Move tests from travis to Github actions
- Add information about cloud reporting in the tool output HOT 1
- Report used NIC for network connection HOT 1
- Make sure firmware upload failure doesn't flag the whole acquisition as failed HOT 1
- Add hotkey to start autoacquire HOT 1
- Bug: not really asking user for input
- For logical acquisition consider using a better tool than find+stat for the timeline
- Add an option for encryption of uploaded artifacts
- Crash when diskutil list -plist doesn't return a binary plist
- Try to upload the "disk list" artifact before failing if no disk is detected
- Error when starting zenity with --select_disk
- Change AskDiskList to present only the disks that is not the one to boot GiftStick HOT 3
- Move to supporting xubuntu 22.04 as base ISO HOT 1
- Consider not using boto HOT 1
- FR: If uploading to GCP, check md5
- ProgressBar raises exceptions
- Enabling Stackdriver logging causes duplicate output
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from giftstick.