geekcomputers / geekcomputers/Python

Written a python script to map device with specific host adapter...

Open
#11 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
35.4k
Forks
12.9k
Avg merge
2h 37m
Merged PRs (30d)
1

Description

!/bin/env python

import glob
import os,sys
import re

if sys.version_info < (2, 6) and sys.version_info < (2, 7):
print "This is not valid version"
sys.exit()

if sys.platform != "linux2":
print "This is not valid OS"
sys.exit()

os.chdir('/sys/block/')

dev_list = ['sd.','mmcblk']

def size(dev):
nr_sectors = open(dev+'/size').read().rstrip('\n')
sect_size = open(dev+'/queue/hw_sector_size').read().rstrip('\n')

# The sect_size is in bytes, so we convert it to GiB and then send it back
return (float(nr_sectors)*float(sect_size))/(1024.0*1024.0*1024.0)

def device_detail():
for dev in glob.glob('/sys/block/sd*'):
vendor_name = open(dev+'/device/vendor','r').read().rstrip('\n')
Read_link = os.readlink(dev).split('/')[4]
print ('Device {0}:: Size {1} GB :: Vendor {2}:: Controller {3}'.format(dev, size (dev), vendor_name, Read_link))

if name =='main':
device_detail()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Python script in the issue and its use of Linux /sys/block entries, device links, sector sizes, and vendor data. No repository file or test is named, so first determine where this script belongs and how it should be run. Done should be a working Linux-compatible device-mapping example with its intended output and validation clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.