Bladeren bron

Adding ascii_only and dd sparse file

Creating sparse files for loopback images can be done with the dd
command. The ascii_only strips all non-ascii characters out of a
string.
master
Nate Bohman 6 jaren geleden
bovenliggende
commit
10205bd258
2 gewijzigde bestanden met toevoegingen van 16 en 0 verwijderingen
  1. +3
    -0
      dd_create_sparse_file
  2. +13
    -0
      python_utils/ascii_only.py

+ 3
- 0
dd_create_sparse_file Bestand weergeven

@@ -0,0 +1,3 @@
# Create sparse.img with 100G (1K * 104857600) and
# actually transfer 0 K into it (count).
dd of=sparse.img bs=1k seek=104857600 count=0

+ 13
- 0
python_utils/ascii_only.py Bestand weergeven

@@ -0,0 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re

logger = logging.getLogger(__name__)

ascii_characters = [chr(i) for i in range(32,127)]
ascii_char_rgx = re.compile("{}".format(re.escape(ascii_characters)))


def ascii_only(incoming_string):
return control_char_rgx.sub("", incoming_string)

Laden…
Annuleren
Opslaan