Basic web scraping - Part 2: thoughts on debugging and Python3

Update: 2020-04-13. The main article has been overhauled and republished here! Includes Python3 updates, Dropbox uploading and a code repo.

I’m leaving the below in place for info and posterity and for misc useful tidbits.


A while ago, I posted a basic tutorial on how to do some simple web scraping in Python using requests and beautifulsoup.

It obviously got found in Google because the hits were good. There were however, a couple of comments highlighting issues with it - Brett and Sean saying issues with “TypeError: ‘NoneType’ object is not callable”

Read more

Sharepoint - Open .eml files in Outlook

If you use email enabled document libraries or indeed any other method of storing email messages (commonly created in Exchange / Outlook) in Sharepoint document libraries then they are more than likely stored in .eml format (that first appeared in Outlook Express) as opposed to the more modern .msg format. .eml is a nice format, which was defined in MIME RFC 822 but because it’s so heavily ingrained in to a Windows environment there can be a less than desirable experience when operating with it in a Sharepoint context.

Read more

Basic web scraping with a Raspberry Pi, Python and Requests

Update: 2020-04-13. Article has been overhauled and republished here! Includes Python3 updates, Dropbox uploading and a code repo.

I’m leaving the below in place for background, info and posterity and for misc useful tidbits.


Update: 2019-05-13 - this has been edited to fix a little bug in the code transcript. There is also a follow-up article on working with Python3 here.

_Update: 2019-12-16 - looks like MagPi have amended their page so the code as below won’t work directly. I’ve left it there for interest but see one of the comments which has amended code. Thanks to Dave for pointing this out!
_

Read more

Use DISKPART to bring a disk online

If you’ve recently migrated a VMWare Fusion virtual machine to VMWare ESXi, which itself had multiple disks, you may find that secondary disks don’t show up. You can change this using DISKPART.

In my case, this didn’t happen in a Windows 10 VM with two disks, but did happen in Windows Server 2016 with two disks.

Weird.

Anyway, it’s reasonably easy to fix, using DISKPART.

  1. Open a CMD prompt and type DISKPART
  2. You should got a ACL type auth warning, just OK It
  3. This will open a new console window with DISKPART> prompt
  4. Type LIST DISK
  5. You should see your various disks listed, and one (or more) will be Offline
  6. Type SELECT DISK 1
  7. Type ONLINE DISK
  8. At this point, your disk should appear in Windows Explorer
  9. If you find you cannot create anything on the disk, then it’s possible it’s readonly, in which case
  10. Type ATTRIB DISK CLEAR READONLY

That should be everything you need.

Read more

Migrate VMWare Fusion virtual machines to VMWare ESXi

Way back in 2012, I dabbled with ESXi. In fact, I faced then, moreorless the same problem I was facing a few days ago.

That particular ESXi server didn’t last particularly long - no technical issues, it just didn’t turn out to be the thing I wanted.

Fast forward 6 years, and I found myself in a new situation where having an ESXi host would be useful. We use Azure a lot nowadays, but there are still some scenarios where we’d like some on-premise kit such as developing against Sharepoint. (Although in fairness, I’m not sure anyone really ever *wants* to do that.) I digress.

Read more

SQL Server - quickly delete all tables

With most things in SQL Server it’s tempting to think you can script it. Because most of the time you can.

Recently, I had a requirement to quickly drop everything out of a database (but without actually just dropping the whole database.)

The best option I found, was:

  1. In the database tree view, find the container for the type of objects you want to delete (e.g., tables)
  2. Press F7 to open up the Object Explorer
  3. From here, select all the items you want to delete. Press delete.
  4. This opens up the standard ‘drop item’ dialog, but with all those objects included.
  5. Hit OK

And boom, away it goes. You can repeat this for any database objects by navigating around the Object Explorer. If you wanted to script this, you’d need to (probably) start navigating the master database and get some cursors and whatnot going on.

Read more

Installing SharePoint in standalone / single server mode

In SharePoint 2016, it’s no longer possible to use PSConfig / SharePoint Products Configuration Wizard to provision a single server SharePoint Farm. You’re likely doing this because you just want a single dev environment to… do some stuff. Strangely (more like typically) Microsoft don’t make this particularly easy for you.

Assuming you have the basis of a SharePoint server, i.e., :

  1. Some sort of OS (i.e. Windows Server)
  2. Some sort of SQL Server (i.e., SQL Server 2016)
  3. SharePoint binaries installed

which isn’t connected to a domain, then you likely fire up the Config Wizard, fill in the obvious entries (ie. specify database server, create new farm, provide credentials, etc.) and specify a local account and the “wizard” tells you that local accounts can only be used in stand alone mode. Well, yeah, exactly, that’s what I wanted. But there’s no way past it.

Read more

Sharepoint 2010 - Access denied... even for farm admins

If you’re getting Access Denied for all users even after configured the Super User and Super Reader cache accounts…

I recently deployed a new site collection into a new content database. As soon as I tried to hit it, I got unexpected errors. I checked the logs which revealed the familiar stuff about the portalsuperuser and portalsuperreader accounts not being configured - object cache misses and so on, for example:

Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unneccesary system resources.

Read more

Sharepoint 2010 SP2 installation - variety of issues

I know. Sharepoint 2010. It’s not even. I mean. Just.

Look let’s skip past any discussion about why this is happening in 2018, and just cover the issues, OK?

So. You’re installing SP2 on a Sharepoint 2010 Farm. This may well apply to any CU in fact. And it possibly applies to SP2013+ also - but at least one of these issues is allegedly caused by a CU that was rolled up in SP2.

Right, that’s enough foreplay.

Read more

Bulk delete items and folders from Sharepoint document library using Powershell

I’ll cut to the chase. A lot has been written about how to handle large lists and how to handle bulk deleting things. To summarise: getting all items and iterating one by one is *not* the way to do it.

The right way to do it is to use the ProcessBatchData method on the SPWeb object.

Have done this plenty of times in C# but this time I wanted to cut straight to Powershell. A quick Google later and I found Daniel Root’s boiler plate. It properly handles checked out files as well, and deletes folders. Ideal!

Read more